Click here to Skip to main content
12,948,566 members (61,174 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
When i use code of Url rewriting it works however it disturbs my site at local server can anybody help me out I am using the following code in global.asax file in .net

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 = "/furl/" + 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);
 
        }
    }
Posted 29-Jul-11 3:05am
lavjain369

1 solution

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

Solution 1

Hi,

you haven't mention what issue you are facing. Looking at the code I believe you have to bypass the checking in case of local server. If your local server url is like this
http://localhost:3325/mysite/

then you can see
if (InRequest.Request.RawUrl.Split('/').Length > 3)

will yield true and process accordingly, so either you have to bypass the checking for local server or you have to handle this case. I hope this will help to solve your issue.
  Permalink  
Comments
lavjain 30-Jul-11 10:57am
   
See the path http://www.codeproject.com/KB/aspnet/Friendly_URLs_in_ASPNet.aspx and download the furl.zip and see the site and the site i want to run on server not on local server so what path i assign there

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

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,419
CHill60 3,275
Maciej Los 2,778
Jochen Arndt 1,935
ppolymorphe 1,795


Advertise | Privacy | Mobile
Web01 | 2.8.170524.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2017
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