>>My suggestion was Response.CompleteRequest as a replacement for Response.End.
>
>Thanks, but I do not have access to this method. I have .NET Framework 4.5 installed on my development PC. I assume this will only become available once I switch the application to use .NET Framework 4.5. At this point, I cannot do this as we still have our production environment running on Windows Server 2003.
Sorry, was a but sloppy in my use of namespace. It's HttpApplication.CompleteRequest() - which has been around since 1.1
>Also, this is something I will have to test to see how it goes. It does say at the end that "The CompleteRequest method does not raise an exception, and code after the call to the CompleteRequest method might be executed." So, this is what I am trying to avoid. However, it is unclear if the same effect as I have now will be accomplished when I will use that.
Hard to say without knowing the source (probably hard to say anyway :-{ )
FWIW here's the source for the Response.End() method (which shows it will call CompleteRequest() if it doesn't throw the exception):
public void End() {
if (_context.IsInCancellablePeriod) {
InternalSecurityPermissions.ControlThread.Assert();
Thread.CurrentThread.Abort(new HttpApplication.CancelModuleException(false));
}
else {
if (!_flushing) { // ignore Reponse.End while flushing (in OnPreSendHeaders)
Flush();
_ended = true;
if (_context.ApplicationInstance != null) {
_context.ApplicationInstance.CompleteRequest();
}
}
}
}