简体   繁体   English

为什么Response.Redirect保持加载当前页面?

[英]why Response.Redirect keep load current page?

protected void Page_Load(object sender, EventArgs e)
{
    Response.Redirect("Home.aspx", false);
}

Why my page keep load on default.aspx and not redirect to Home.aspx,After load finish my browser will pop up an error "The page isn't redirecting properly" tell me to clear the cookie but I follow still the same? 为什么我的页面在default.aspx上保持加载而不重定向到Home.aspx,加载完成后,我的浏览器将弹出错误“页面无法正确重定向”,告诉我清除cookie,但我仍然遵循相同的操作?

please visit the following Link 请访问以下链接

Extract from above link 从上面的链接中提取

The HttpResponse class implements two overloaded versions of the Redirect method. HttpResponse类实现Redirect方法的两个重载版本。 The first overloaded method takes only one input parameter, which is the URL for the target location. 第一个重载方法仅采用一个输入参数,即目标位置的URL。 This version is defined as follows: 此版本定义如下:

public void Redirect(string url); 

The second overloaded method takes two input parameters: the URL for the target location, and a boolean value that indicates whether to stop running the current page. 第二个重载方法采用两个输入参数:目标位置的URL和指示是否停止运行当前页面的布尔值。 This version is defined as follows: 此版本定义如下:

public void Redirect(string url, bool endResponse);

When you use the first overloaded version, the second overloaded version is called internally and is passed a boolean value of True for the second input parameter. 当您使用第一个重载版本时,将在内部调用第二个重载版本,并为第二个输入参数传递布尔值True。

Use this 用这个

<%@ Page Language="C#" %>
<script runat="server">
  protected override void OnLoad(EventArgs e)
  {
      Response.Redirect("Home.aspx");
      base.OnLoad(e);
  }
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM