Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference between response.redirect and response status 301 redirects in asp?

Tags:

asp.net

Our ASP application is moving to a new server and I want to implement a permanent URL redirection. I am aware of the following two approaches, but I need to understand which one to use and when.

Option 1:

<%@ Language=VBScript %><% Response.Redirect "http://www.example.com" %>

Option 2:

<%@ Language=VBScript %><% Response.Status="301 Moved Permanently" 
  Response.AddHeader "Location","http://www.example.com/" %>

Thanks,

Nikhil.

like image 734
Nikhil Vaghela Avatar asked Jun 11 '10 19:06

Nikhil Vaghela


People also ask

What is response redirect in ASP NET?

Response. Redirect() should be used when: we want to redirect the request to some plain HTML pages on our server or to some other web server. we don't care about causing additional roundtrips to the server on each request. we do not need to preserve Query String and Form Variables from the original request.

What is the difference between server Transfer & Response redirect?

The Response. Redirect method redirects a request to a new URL and specifies the new URL while the Server. Transfer method for the current request, terminates execution of the current page and starts execution of a new page using the specified URL path of the page.

What is the meaning of 301 redirects?

The HyperText Transfer Protocol (HTTP) 301 Moved Permanently redirect status response code indicates that the requested resource has been definitively moved to the URL given by the Location headers. A browser redirects to the new URL and search engines update their links to the resource.


1 Answers

Response.Redirect issues a 302, which is a temporary redirect. 301, using the Response.AddHeader that you listed, is for permanent redirects.

The differences between 301 and 302 have some importance with search-engine-optimization. A 301 will hold all of your search rankings from the old location. On the flip side, if you DON'T want your new page to be indexed, you can use a Response.Redirect (302) since the engines will consider the redirect temporary. Google doesn't index 302's because a lot of spammers use it to try to increase their rankings.

Since you're permanently moving to a new server, a 301 is the best way to go.

like image 67
Nate Dudek Avatar answered Nov 11 '22 13:11

Nate Dudek