As you've pointed out, the method Response.End is defined as:
public void End()
{
if (this._context.IsInCancellablePeriod) {
InternalSecurityPermissions.ControlThread.Assert();
Thread.CurrentThread.Abort(new HttpApplication.CancelModuleException(false));
}
else if (!this._flushing)
{
this.Flush();
this._ended = true;
if (this._context.ApplicationInstance != null) {
this._context.ApplicationInstance.CompleteRequest();
}
}
}
Debugging a fairly simple web app with a break point in the Page_Load method, I can see the call stack includes the line:
System.Web.dll! System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step = {System.Web.HttpApplication.CallHandlerExecutionStep}, ref bool completedSynchronously = true) + 0x4c bytes
Reflecting into CallHandlerExecutionStep
I can see that the property IsCancellable
is defined as:
bool HttpApplication.IExecutionStep.IsCancellable {
get {
return !(this._application.Context.Handler is IHttpAsyncHandler);
}
}
The default handler for .aspx pages is the output from the PageHandlerFactory
which implement IHttpHandler, not IHttpAsyncHandler - which would result in IsCancellable
returning true (as indeed it does in my test app).
Have you configured a different HttpHandler in either your root web.config or one further up the stack to use an Async Handler instead? Are you using Update Panels with Partial Postbacks for example?