301 redirect to a new page

Discussion in 'ASP.NET / ASP.NET Core' started by bhsiao, Mar 3, 2009.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi,

    I need to redirect an old .aspx page to a new .aspx page with a different same, same root folder. Can anyone tell me what code to put on the page?

    thank you!!!!!!!!!!!!!
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    <%
    response.redirect("newpage.aspx")
    %>
     
  3. Thank you

    Thank you! I think discountasp should put that in their knowledge base and tell their tech support about that simple solution. It is so much easier to understand than what they tried to get me to do! (and...it works!)
     
  4. Just a note to the OP that this will perform a redirect but it will be a 302 temporary redirect in the HTTP header and not a 301 permanent redirect...this may or may not matter depending on the client reading the header.
     
  5. redirect

    How temporary? How do i make it permanent?
     
  6. Temporary forever if you leave the code as is, which sometimes will not be good for SEO if you're doing this on a website landing page (default.aspx, default.htm etc) because crawlers like Googlebot will prefer to see a 301 permanent redirect instead of a 302 temporary redirect.

    To perform a 301 in .NET code, you need to write the status and header info explicitly. This can be done at page level, global.asax or IHttpModule depending on your needs. There are a couple of examples here: http://www.aspcode.net/ASPNET-301-redirect.aspx

    Whatever you end up doing, I'd recommend checking the result with a couple of external redirect checkers like:
    http://www.webconfs.com/redirect-check.php and
    http://www.internetofficer.com/seo-tool/redirect-check/

    Use a few different ones because they vary in reliability of reporting headers correctly. In addition personally I like the LiveHttpHeaders add on for Firefox - it's a decent method of seeing the headers (and other info) for pages you request locally.

    Edit - here's another related post:
    http://forum.discountasp.net/showthread.php?t=7252
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page