Routing Classic ASP Requests To .NET - SEO Redirects

后端 未结 4 1658
梦如初夏
梦如初夏 2021-01-06 05:18

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

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-06 05:35

    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

提交回复
热议问题