Follow in Twitter & Facebook

Like in Facebook

Powered By Blogger Widgets

Free Download

FREE Tools

Saturday, February 18, 2012

Redirect from to

If you want to redirect from to in application, then you can do it through IIS settings, but you can do it through code file also.

You can write the code in the global.asax file in the Application_BeginRequest method.

void Application_BeginRequest(object sender, EventArgs e)
        string FromHomeURL = "";

        string ToHomeURL = "";

      if (HttpContext.Current.Request.Url.ToString().ToLower().Contains(FromHomeURL))

            HttpContext.Current.Response.Status = "301 Moved Permanently";


            Request.Url.ToString().ToLower().Replace(FromHomeURL, ToHomeURL));


You can also check a good article on Page Lifecycle Events in ASP.Net.

0 on: "Redirect from to"