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.
Response.Endwill only raiseThreadAbortExceptionwhenHttpContext.IsInCancellablePeriodis true.One side effect of
Response.Flush()is that is causesHttpContext.IsInCancellablePeriodto 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.