aspx page to redirect to a new page

后端 未结 8 1514
予麋鹿
予麋鹿 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:05

    In a special case within ASP.NET If you want to know if the page is redirected by a specified .aspx page and not another one, just put the information in a session name and take necessary action in the receiving Page_Load Event.

    0 讨论(0)
  • 2020-12-02 20:07

    Redirect aspx :

    <iframe>
    
        <script runat="server">
        private void Page_Load(object sender, System.EventArgs e)
        {
        Response.Status = "301 Moved Permanently";
        Response.AddHeader("Location","http://www.avsapansiyonlar.com/altinkum-tatil-konaklari.aspx");
        }
        </script>
    
    </iframe>
    
    0 讨论(0)
  • 2020-12-02 20:11

    Or you can use javascript to redirect to another page:

    <script type="text/javascript">
        function toRedirect() {
            window.location.href="new.aspx";
        }
    </script>
    

    Call this toRedirect() function from client (for ex: onload event of body tag) or from server using:

    ClientScript.RegisterStartupScript(this.gettype(),"Redirect","toRedirect()",true);
    
    0 讨论(0)
  • 2020-12-02 20:13
    <%@ Page Language="C#" %>
    <script runat="server">
      protected override void OnLoad(EventArgs e)
      {
          Response.Redirect("new.aspx");
      }
    </script>
    
    0 讨论(0)
  • 2020-12-02 20:17

    Even if you don't control the server, you can still see the error messages by adding the following line to the Web.config file in your project (bewlow <system.web>):

    <customErrors mode="off" />
    
    0 讨论(0)
  • 2020-12-02 20:21

    If you are using VB, you need to drop the semicolon:

    <% Response.Redirect("new.aspx", true) %>
    
    0 讨论(0)
提交回复
热议问题