301 Redirect in ASP.NET - The SEO friendly redirect

301 redirects in ASP.NETWhen you run a website, there are times that you'll need to redirect webpages to other webpages. There are two key ways to accomplish this task, issuing a 301 redirect or a 302 redirect. What you might not know is that a 301 redirect is search engine friendly and a 302 redirect is not. 301’s will safely tell the search engines that one page has been permanently moved to a new location, while 302’s tell the search engines that it’s a temporary redirect (which can cause problems down the line.) This shouldn’t be news for anyone working in the search industry, but might be news for website owners outside of the industry.

Since most redirect in ASP.NET are 302's, we need a way to get a 301 redirect in code that is much more SEO  friendly. I included a piece of code to show you how this is done.

Add these lines of code to your Page_Load event to get a 301 redirect:

Response.Status = "301 Moved Permanently";
Response.AddHeader("Location",
http://www.your-new-location.com);
Response.End();

 

Tags: ,

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading


Björn Bailleul

Web application engineer and developer interested in creating customer centric applications build for ease of use and efficiency. My experience goes from intranet applications to widely used service websites, product portfolios and e-commerce websites.

Specialties

C#, MVC, AJAX, ASP.NET, SQL Server, SQL Reporting Services, WCF, XML, HTML, JavaScript, CSS, Web Services, Scrum, ...

View Bjorn Bailleul's profile on LinkedIn

Month List