ASP.NET 4.0 SEO features: Response.RedirectPermanent()
ASP.NET 4.0 introduces some SEO improvements. Response has now new method calledRedirectPermanent(). This method performs same redirect as Response.Redirect() but it uses response code 301. You can find more information about HTTP response codes from HTTP 1.1 specification, chapter 10. Status Code Definitions.
Response.Redirect() returns 302 to browser meaning that asked resource is temporarily moved to other location. Permanent redirect means that browser gets 301 as response from server. In this case browser doesn’t ask the same resource from old URL anymore – it uses URL given by Location header.
To illustrate difference between Response.Redirect() and Response.RedirectPermanent() let’s look at simple example. We need one usual ASP.NET Web Application with Global.asax file. In Global.asax file we have to implement BeginRequest() method.
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (Request.FilePath == "/our-products.aspx")
{
Response.Redirect("/products.aspx", true);
}
if (Request.FilePath == "/about-us.aspx")
{
Response.RedirectPermanent("/about.aspx", true);
}
}
Now let’s run our web application and make the following requests:
- /our-products.aspx
- /about-us.aspx
In both cases we will be redirected but redirections are different. Here is my little mix of FireBug outputs for these requests and I think it is very self describing.
Response.RedirectPermanent() has also overload with one parameter, just like Response.Redirect() does. If you have pages that exist in search engines but are moved to other location in your application then Response.RedirectPermanent() helps you build redirection controlling mechanism that likes to search engine spiders.
Thank you Gunnar for your excellent previews of Asp.Net 4 !
– Joe
also:
Response.Clear();
Response.Status = “301 Moved Permanently”;
Response.RedirectLocation = PathOrUrl;
Response.End();
Because it sends out response to client. Not every HTTP request ends up with response that is shown to user as page. 301 and 302, by example, return header called Location that contains URL of page where client should go instead.
302 is temporary redirect and that means that resource may be soon available in current address again. So, client has to check it always when the request is made. 301 is permanent redirect that tells client that resource is moved to another address and it will not be available on current address ever again.
One of those clients is your browser and the other one is search engine spider. The last one doesn’t like those 302 responses and that’s why RedirectPermanent is important.
Response.RedirectPermanent() is server side mechanism then how it’s work for SEO ?
thanks for informing me. Can we make database programmes in mysql without making dsn..?
Thanks to expose nice feature of .net 4.0.
nice information but i have one question can one told me what happen if we used redirectpermanently.
will it effect on search engine pages that it index ?
what happen if we redirect paramently that page that Google index ? Page index remain or removed from the google.
any told me ?
thanks in advance
yasir butt
It is good that we have this option available to redirect.
I was looking to redirect all “non www” urls to “www urls”. Can we do this at the server level(IIS 7 available available through websitepanel) itself or this is the only way available?
This is a really good read for me. Must admit that you are one of the best bloggers I have ever read. Thanks for posting this informative article.love it.
Hello! Just want to say thank you for this interesting article! =) Peace, Joy.