aspx page to redirect to a new page

后端 未结 8 1515
予麋鹿
予麋鹿 2020-12-02 19:53

What is the code required to redirect the browser to a new page with an ASPX page?

I have tried this on my page default.aspx :

<% Response.Redirec         


        
相关标签:
8条回答
  • 2020-12-02 20:23

    You could also do this is plain in html with a meta tag:

    <html>
    <head>
      <meta http-equiv="refresh" content="0;url=new.aspx" />
    </head>
    <body>
    </body>
    </html>
    
    0 讨论(0)
  • 2020-12-02 20:23

    Darin's answer works great. It creates a 302 redirect. Here's the code modified so that it creates a permanent 301 redirect:

    <%@ Page Language="C#" %>
    <script runat="server">
      protected override void OnLoad(EventArgs e)
      {
          Response.RedirectPermanent("new.aspx");
          base.OnLoad(e);
      }
    </script>
    
    0 讨论(0)
提交回复
热议问题