Enter your email address:


feedburner count

Asp.net Tip series #2: How to rewrite url request ?

Wondering how to transfer "http://www.lethanhhung.com/TitleOfPage" into "http://www.lethanhhung.com/page.aspx?title=TitleOfPage"
So , you want to do that, remember there is aApplicationBeginRequest in global.asax? ApplicationBeginRequest is fired BEFORE the actual page, so we override redirecting job here :

protected void ApplicationBeginRequest(Object sender, EventArgs e)
{
string path = Request.ServerVariables[“PATH
INFO”];
string filename;

filename = path.Substring(path.LastIndexOf(“/”));
string destinationUrl = “/page.aspx?title=” + filename;
Server.Transfert(destinationUrl);
}




blog comments powered by Disqus