Monday, February 16, 2009

301 Redirect in ASP.NET / C# Code

If you want to redirect a URL on a permanent basis using ASP.NET and C# code as an alternative to using IIS 6 or IIS 7, you can append the code to the old ASP.NET page.


Response.Clear();
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", "http://www.newpagelocation.com/");
Response.End();

Hope this helps!