asp.net - Page_Load 中的 Response.Redirect

标签 asp.net response.redirect

我的 Page_Load 中有一个 Response.Redirect:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    ...Code
    Response.Redirect("http://www.mysite.com")
End Sub

在添加 Response.Redirect 之前,我还有其他带有工作代码的子例程

添加Response.Redirect后,它们都不会处理其代码并自动执行Response.Redirect网站。

当没有Response.Redirect时,我的代码可以工作。

最佳答案

使用

Response.Redirect("http://www.mysite.com",  false)

第二个参数指示当前页面的执行是否应终止。

如果您使用Response.Redirect("http://www.mysite.com"),当前页面执行将终止

关于asp.net - Page_Load 中的 Response.Redirect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20579613/

相关文章:

c# - 我如何找到我得到 "Exception of type ' System.Web.HttpUnhandledException' 被抛出的原因?

Node.js 响应带有 token ,然后 res.render 或重定向

c# - 使用主页时 Response.Redirect 的问题

c# - Response.Redirect 正在执行 POST 而不是 GET

java - 带有外来字符的 url 的 response.sendredirect - 如何编码?

asp.net - 蜘蛛抓取期间与事务相关的各种 NHibernate 错误

asp.net - asp.net MVC 中的用户登录

javascript - 如何使用 asp.net 从文本框中调用函数?

c# - 通过 javascript PageMethods 调用 WebMethod 时触发 Page_Load

c# - 重定向到隐藏查询字符串参数的页面asp.net