Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Response.Redirect uses 302 instead of 301

using the following code

context.Response.StatusCode = 301;  context.Response.Redirect(newUrl, true); context.Response.End(); 

I can see in fiddler that it's using a 302 instead of a 301. Should I be setting the status after the redirect call?

like image 257
ILovePaperTowels Avatar asked Sep 19 '11 23:09

ILovePaperTowels


People also ask

How do you fix a 302 redirect?

How to fix it? You should only use 302 redirects where the redirection is temporary and content will come back to the original URL soon. Check the reported URLs. Where the redirection is permanent, change the redirection to 301 (Moved Permanently).

Which is better 301 or 302 redirect?

Each redirect serves a different purpose. For a permanent change that will rank for SEO, a 301 redirect is necessary and understood by search engines. 302 redirect should only be used if it is a temporary change, and they often get used because it's easier to create that instance than the permanent 301 redirect.

Is 302 permanent redirect?

What is a 302 redirect? Whereas a 301 redirect is a permanent relocation of your URL, a 302 redirect is a temporary change that redirects both users and search engines to the desired new location for a limited amount of time, until the redirect is removed.

What are 302 redirects used for?

A 302 redirect lets search engines know that a website or page has been moved temporarily. When Should You Use 302 Redirects? Use this type of redirect if you want to send users to a new site or page for a short period of time, such as when you're redesigning or updating your website.


1 Answers

If you're using ASP.Net 4.0, you can use Response.RedirectPermanent, which will use 301 instead of 302.

like image 195
Adam Butler Avatar answered Sep 20 '22 17:09

Adam Butler