Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

URL Rewrite does not work

$
0
0

Hi,

I had an old website with url domain.com/mobile. Now my new site is fluid with all devices. Therefore, domain.com/mobile has become to domain.com.

I have added the following code to Global, but it does not redirect, running into server error 500.

void Application_BeginRequest(object sender, EventArgs e)
{
if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("/mobile"))
{
Response.Clear();
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.RedirectPermanent(Request.Url.ToString().ToLower().Replace("/mobile", ""));
}
}

Can anyone help me with this?

Thank you.


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>