Quantcast
Channel: Configuration and Deployment
Viewing all articles
Browse latest Browse all 3561

URL Redirect at Application Level

$
0
0

Hi,

I had a old website with a domain www.mydomain.com,and on mobile, it was www.mydomain.com/mobile.

Now, my new site is fluid with all types of device. www.mydomain.com/mobile no longer exists. What I want to do is this: When the application loads, check if the requested URL contains "/mobile", if it does, replace with nothing and redirect. I have this code.

void Application_Start(object sender, EventArgs e)
{
    string url = HttpContext.Current.Request.Url.AbsoluteUri;
    if (url.IndexOf("/mobile") > -1)
    {
       url = url.Replace("/mobile", "");
       Response.Redirect(url);
     }
}

No matter which page is requested, I only need to remove "/mobile" from the URL, and redirect.

I tried to put this code on master page, on default, and then on Global. None of them redirect. Could someone tell me how to implement this?

Thank you immensely.

Ella


Viewing all articles
Browse latest Browse all 3561