【问题标题】:How can I redirect a web page in Asp.Net?如何在 Asp.Net 中重定向网页?
【发布时间】:2011-10-01 01:43:56
【问题描述】:

如何在 Asp.Net 中将 www.xxx.com/hakkimda.aspx 页面重定向到 www.xxx.com/default.aspx?=hakkimda?

【问题讨论】:

    标签: asp.net url redirect


    【解决方案1】:

    网址更改,[onserver]

    Response.Redirect("Default2.aspx?foo=baar",true);
    

    网址保持不变[在服务器上]

    Server.Transfer("Default2.aspx?poop=baar");
    

    网址更改 [在客户端]

    <script type="text/javascript">
         window.location="http://som_eother_location.html"
    </script>
    

    【讨论】:

      【解决方案2】:
      <script runat="server">
      private void Page_Load(object sender, System.EventArgs e)
      {
      Response.Status = "301 Moved Permanently";
      Response.AddHeader("Location","www.xxx.com/default.aspx?=hakkimda");
      }
      </script> 
      

      【讨论】:

      • 请记住,如果使用此信息,此信息将存储在访问者的缓存中,并且在尝试访问该站点时将始终被重定向,甚至无需联系服务器。如果不需要,请使用“307 临时重定向”。
      【解决方案3】:
      【解决方案4】:
      Response.Redirect("default.aspx", True)
      

      或者简单的Response.Redirect("TeleCmslogin.aspx") 希望以上代码对你有所帮助。

      【讨论】:

        【解决方案5】:

        真的,最简单的方法是 javascript。

        <script type="text/javascript"> window.location.href = "www.xxx.com/default.aspx?=hakkimda"; </script>
        

        【讨论】:

          【解决方案6】:

          你应该输入:

             using system.web.security;
          

          然后输入页面加载:

            if (!Request.IsAuthenticated)
              {
                  Response.Redirect("~/default.aspx");
              }
          

          【讨论】:

            猜你喜欢
            • 2012-12-12
            • 2012-04-14
            • 1970-01-01
            • 1970-01-01
            • 2013-08-15
            • 2014-09-27
            • 2018-10-21
            • 2019-08-08
            相关资源
            最近更新 更多