C# 4.0: Response.RedirectPermanent

By Peter Bromberg

ASP.NET 4.0 introduces some SEO improvements. Response has a new method; RedirectPermanent(). This performs a redirect but it uses response code 301, which means that search engines and bookmarks will automatically go to the new page as if the original requested page does not even exist. Search engines will index the new target page only. The original Response.Redirect() returns a 302 to the browser meaning that the resource has temporarily moved to another location.

A permanent redirect means that the browser receives a 301 response from server. In this case the browser (or crawler) will not ask for the same resource from the old URL anymore – it will use the URL given by the Location header.

If you have a page on your site that, for one reason or another, is being retired, the best thing to do is make it into a "script-only" stub that performs the new Response.RedirectPermanent call to the new, correct resource.

This can be as simple as a page with no codebehind class file:

<%@ Page Language="C#" %>
<script runat="server" language="C#">
void Page_Load()

C# 4.0: Response.RedirectPermanent  (1861 Views)