To rewrite the url only using asax file like www.domain.com/items.aspx?ID=1
to www.domain.com/fackurl.aspx?ID=1 Add the below content in the Global.asax file
Tags: url rewriting in asp.net sample code, url rewriting using global.asax asp net, url rewriting with global.asax, url rewriting using global.asax asp net
to www.domain.com/fackurl.aspx?ID=1 Add the below content in the Global.asax file
protected void Application_BeginRequest(object sender, EventArgs e)
{
HttpContext myContext = HttpContext.Current;
Regex rewrite_regex = new Regex(@"(.+)\/((.+)\.aspx)", RegexOptions.IgnoreCase);
try
{
//see if we need to rewrite the URL
Match match_rewrite = rewrite_regex.Match(myContext.Request.Path.ToString());
if (match_rewrite.Groups[2].Captures[0].ToString() == "Default.aspx")
{
if (Request.QueryString["ID"] != null)
myContext.RewritePath("~/Mail/Index.aspx?ID=" + Request.QueryString["ID"].ToString(), true);
}
}
catch (Exception ex) { }
}Tags: url rewriting in asp.net sample code, url rewriting using global.asax asp net, url rewriting with global.asax, url rewriting using global.asax asp net
No comments:
Post a Comment