top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

What is RedirectPermanent in ASP.Net 4.0?

0 votes
21 views
What is RedirectPermanent in ASP.Net 4.0?
posted May 12, 2017 by Jdk

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

0 votes

Full domain redirects like the one you mention are best done at the IIS level, but if you aren't able to configure IIS you could use Response.RedirectPermanent, which is new in ASP.NET 4.0. This will redirect with a 301 (permanent) status code instead of the 302 (object moved) status code used by a standard Response.Redirect.

Put this code inside Global.asax file:

protected void Application_BeginRequest(object sender, EventArgs e)
{
    if (!(Request.Url.AbsoluteUri.ToLower().Contains("www")))
    {
      Response.RedirectPermanent(Request.Url.AbsoluteUri.Replace("http://", "http://www."));
    }
} 
answer May 12, 2017 by Shweta Singh
Similar Questions
+7 votes

How to create your own controls?
Basic steps will be helpful.

+4 votes

How to Generic Method to Create and Execute Parameterized SQL Query in .NET 4.0 ?

+2 votes

How to use Zip operator in Linq with .NET 4.0?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...