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.