Posted by in ASP.NET category on for Beginner level | Views : 6799 red flag

The easiest way to make a redirection in ASP.NET is using Response.Redirect(url).

What it actually does is, that it creates a response with the "302 (Object Moved)" status code and the target destination.

It tells the browser that the requested page is temporarily moved to a new location and then the browser makes a request to the new destination.

If the page is permanently moved, then the 302 status code is no longer correct.

Search engines also looks at 301 and 302 redirects differently. Here's a quote from The Internet Digest:

There is no natural way of doing a 301 redirect in ASP.NET, so you have to set the HTTP headers manually.

Below given is a small method that illustrates how to do it. All you have to do is to call it from the Page_Load or preferably from Page_Init or in ASP.NET 2.0 Page_PreInit.
protected void Page_PreInit(object sender, EventArgs e)





private void PermanentRedirect(string url)



Response.StatusCode = 301;

Response.AppendHeader("location", url);


Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: Amit Gupta
Member Level: Starter
Member Status: Member
Member Since: 7/23/2007 11:05:49 PM
His experience covers a wide range of spectrum: SEO, Analytics, consultant, technical editor and college instructor . Amit holds more than 3 technical certifications and has completed MCA. Amit may be reached at

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)