Calling HttpContext::PostCompletion method twice may cause crash

Applies to: Internet Information Services 8.0

Summary


Consider the following scenario:

You are developing an IIS module which calls PostCompletion twice. In this scenario, on the second call to PostCompletion, your web application crashes with an Access Violation.

Cause


PostCompletion indicates that an HTTPRequest has completed. Thus the HttpContext object is no longer available so the second call to the HttpContext object's PostCompletion method causes an Access Violation.

More Information


IHttpContext::PostCompletion Method
http://msdn.microsoft.com/en-us/library/ms692997(v=vs.90).aspx

If you are calling PostCompletion then put a guard (e.g.: check if HttpContext is not null) around it to avoid crash if it is invoked automatically.