We are replacing an old classic asp website with a .NET 3.5 solution.
We need to redirect all of the classic ASP requests to aspx pages (i.e. contactus.asp, may now
Eduardo Molteni's answer works, except for one thing. It actually passes the browser a 302 instead of a 301.
I believe instead of:
Context.Response.StatusCode = 301
Context.Response.Redirect("/something/")
it should be:
Context.Response.StatusCode = 301
Context.Response.RedirectLocation = "/something")
The response.redirect is basically interrupting what you were setting up with the Response.StatusCode and the browser ends up getting a "302 Found".
I'm not really sure how search engines handle a 302 vs a 301 so maybe its not an issue. It seems to me though that a true Permanent Redirect (301) would be preferred.
For those on v4 of the framework, there seems to be a new option:
Response.RedirectPermanent("/something")
I haven't tested this, but I'm assuming it provides a 301 as the status code. Details here: HttpResponse.RedirectPermanent