Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET .NET IIS Microsoft , +
When I use Global.asax file for url rewriting purposes, I use Application_BeginRequest and follow up the code :
 

protected void Application_BeginRequest(object sender, EventArgs e)
       {
            //Get the current http context
             HttpContext InRequest = HttpContext.Current;
 
             //Get the current path
             string OldPath = InRequest.Request.Path.ToLower();
 
             //Check the path whether it is a contextual path
             if (InRequest.Request.RawUrl.Split('/').Length > 3)
             {
                 string Path = InRequest.Request.RawUrl.Split('/')[2];
 
                 Path = "/" + Path + "/";
 
                 string NewPath = "/abc/" + WebConfigurationManager.AppSettings[Path];
 
                 string ItemName = InRequest.Request.RawUrl.Split('/')[InRequest.Request.RawUrl.Split('/').Length - 1].Split('.')[0];
 
                 string ID = InRequest.Request.RawUrl.Split('/')[3];
 
                 //Rewrite the path with the actual path
                 InRequest.RewritePath(NewPath, "", "?id=" + ID, true);
 
             }
       }
However the Code is working fabulous but it dusturbs my website design when i run on local host, I think their is problem with iis can anyone help me?
Posted 23-Dec-12 3:14am
lavjain369
Comments
VishwaKL at 24-Dec-12 5:00am
   
Check it on locally, may be problem with CSS
digimanus at 24-Dec-12 10:19am
   
Have you read this ?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

RewritePath according to MSDN makes a new request:
See http://msdn.microsoft.com/en-us/library/system.web.httpcontext.rewritepath.aspx[^]
 
First line in text:
Redirects a request for a resource to a different path than the one that is indicated by the requested URL. RewritePath is used in cookieless session state to strip session IDs from URLs.
  Permalink  
Comments
ArpitDubey at 28-Dec-12 16:00pm
   
i had same issue before i switched to http://urlrewriter.net/
no need to touch global.asax any more, just stuff in web.config

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 590
1 OriginalGriff 535
2 CPallini 285
3 Peter Leow 185
4 RyanDev 161
0 OriginalGriff 5,784
1 Sergey Alexandrovich Kryukov 4,838
2 Peter Leow 3,009
3 Maciej Los 2,894
4 DamithSL 2,465


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 24 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100