IIS7集成管道-Response.End未结束请求
在我们升级到 IIS7 中的集成管道之前,我有以下代码可以按预期工作。
public void RedirectPermanently(string url, bool clearCookies)
{
Response.ClearContent();
Response.StatusCode = 301;
Response.AppendHeader("Location", url);
if(clearCookies)
{
Response.Cookies.Clear();
Response.Flush();
Response.End();
}
}
以前执行此方法时,如果clearCookies为true,则响应将发送到客户端,请求处理将结束。现在在集成管道 Response.End() 下似乎没有结束处理。该页面继续运行,就好像该方法从未被调用过一样。
大问题是,为什么发生变化以及发生了什么变化!
谢谢。
I have the following bit of code that worked as expected before we upgraded to Integrated Pipeline in IIS7.
public void RedirectPermanently(string url, bool clearCookies)
{
Response.ClearContent();
Response.StatusCode = 301;
Response.AppendHeader("Location", url);
if(clearCookies)
{
Response.Cookies.Clear();
Response.Flush();
Response.End();
}
}
Previously when this method was executed, if clearCookies was true, the response would be sent to the client and request processing would end. Now under Integrated Pipeline Response.End() does not seem to end processing. The page continues running as if the method was never called.
Big question is, why and what changed!
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当
HttpContext.IsInCancellablePeriod
为 true 时,Response.End
只会引发ThreadAbortException
。Response.Flush()
的一个副作用是,在集成管道模式下执行时,会导致HttpContext.IsInCancellablePeriod
变为 false。尝试从代码中删除
Response.Flush()
。无论如何,结束响应都会导致响应流被刷新。Response.End
will only raiseThreadAbortException
whenHttpContext.IsInCancellablePeriod
is true.One side effect of
Response.Flush()
is that is causesHttpContext.IsInCancellablePeriod
to become false when executing in integrated pipeline mode.Try removing
Response.Flush()
from your code. Ending the response will cause the response stream to be flushed anyway.