ASP.Net and C# and DotNet and SEO | 25 Apr 2008 04:34 am

Hello there,

If you were wondering how to do search engine friendly urls in asp.net go no further. The key is the Global.asax file in your root. Put this code in for this example to get the number after /search/dist/ and run the file specified. :-

1
2
3
4
5
6
7
8
9
10
11
 protected void Application_BeginRequest(Object sender, EventArgs e)
{
HttpContext incoming = HttpContext.Current;
string oldpath = incoming.Request.Path.ToString();
if(oldpath.Contains("/search/dist/")){
string[] sstring =new string[6];
sstring=oldpath.Split('/');
//Web_Security.SearchDistributions=Convert.ToInt32();
incoming.RewritePath("~\\search\\Default.aspx?dist=" + sstring[4]);
}
}

Trackback this Post | Feed on comments to this Post

Leave a Reply

You must be logged in to post a comment.