从 ICallbackEventHandler.RaiseCallbackEvent 中调用 Response.RedirectLocation 不会执行任何操作
我们正在尝试在页面回调期间进行重定向。我们有一个正在实现 ICallbackEventHandler 的 aspx 页面。在代码隐藏的 ICallbackEventHandler.RaiseCallbackEvent() 事件处理程序内部,我们尝试使用 Response.RedirectLocation 将用户移动到另一个 aspx 页面。我们的代码如下。
void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
{
HttpContext.Current.Response.RedirectLocation = "http://www.google.com";
HttpContext.Current.Response.End();
}
在引发事件客户端并在事件处理程序中设置断点后,我们确信代码正在被调用,但页面实际上并未重定向。我们在这里遗漏了一些重要的东西吗?我们尝试了其他几种方法,包括设置 Response.StatusCode 和使用 Flush() 而不是 End()。如果您需要有关我们正在尝试做的事情的任何其他信息,请告诉我。
任何想法将不胜感激!
谢谢, 丹尼尔
We're attempting to make a redirect during a page callback. We have an aspx page that is implementing ICallbackEventHandler. Inside of the ICallbackEventHandler.RaiseCallbackEvent() event handler in the code-behind we're attempting to use the Response.RedirectLocation to move the user on to another aspx page. Our code is below.
void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
{
HttpContext.Current.Response.RedirectLocation = "http://www.google.com";
HttpContext.Current.Response.End();
}
After raising the event client-side and setting breakpoints in the event handler we are sure that the code is being called but the page doesn't actually redirect. Are we missing something important here? We've tried several other ways including setting the Response.StatusCode and using Flush() instead of End(). Let me know if you need any additional information about what we're trying to do.
Any ideas would be greatly appreciated!
Thanks,
Daniel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在没有最后一行的情况下完成了它并且它有效。
HttpContext.Current.Response.RedirectLocation = "http://www.google.com";
I did it without the last line and it works.
HttpContext.Current.Response.RedirectLocation = "http://www.google.com";
老式的方法是
Response.Redirect(url)
。这能解决问题吗?The old fashioned way was
Response.Redirect(url)
. Does that fix it?