简体   繁体   English

从ICallbackEventHandler.RaiseCallbackEvent内调用Response.RedirectLocation不执行任何操作

[英]Calling Response.RedirectLocation from within ICallbackEventHandler.RaiseCallbackEvent does nothing

We're attempting to make a redirect during a page callback. 我们正在尝试在页面回调期间进行重定向。 We have an aspx page that is implementing ICallbackEventHandler. 我们有一个实现ICallbackEventHandler的aspx页面。 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. 在代码背后的ICallbackEventHandler.RaiseCallbackEvent()事件处理程序内部,我们尝试使用Response.RedirectLocation将用户移动到另一个aspx页面。 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(). 我们尝试了其他几种方法,包括设置Response.StatusCode以及使用Flush()而不是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 谢谢,丹尼尔

I did it without the last line and it works. 我没有最后一行就做到了,而且有效。

HttpContext.Current.Response.RedirectLocation = " http://www.google.com "; HttpContext.Current.Response.RedirectLocation =“ http://www.google.com ”;

The old fashioned way was Response.Redirect(url) . 老式的方法是Response.Redirect(url) Does that fix it? 这样可以解决吗?

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

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