asp.net - sporadic NullPointerException in CurrentModuleContainer.Get Asp .Net code when doing async handling -


I have an ASP. Net application for which I am using new async /. 4.5 4.5 I am awaiting a paradigm with RC. I am using a new work-based async http handler HttpTaskAsyncHandler to handle HTTP requests. In my code, I am streaming a file to some I / O customer.

Once I am receiving a NullPointerException with the following stack trace:

System.Web.dll! System.Web.HttpApplication.CurrentModuleContainer.get () + 0x1e bytes System.Web.dll! System.Web.HttpApplication.PipelineStepManager.ResumeSteps (System.Exception Error) + 0xb7 bytes
System.Web.dll! System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion (System.IAsyncResult AR) + 0x1f3 bytes
mscorlib.dll! System.Threading.Tasks.Task.Execute () + 0x6e bytes Mscorlib.dll! System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext ExecutionContext, System.Threading.ContextCallback Callback, Object Status, Protects boolSyncCtx) + 0x285 bytes mscorlib.dll! System.Threading.ExecutionContext.Run (System.Threading .ExecutionContext ExecutionContext, System.Threading.ContextCallback Callback, Object State, preserve boolSyncCtx) + 0x 9 bytes
mscorlib.dll! Sys tem.Threading.Tasks.Task.ExecuteWithThreadLocal (Reference System.Threading.Tasks.Task currentTaskSlot) + 0x1c5 bytes
mscorlib.dll! System.Threading.Tasks.Task.ExecuteEntry (bool bPreventDoubleExecution) + 0xb0 bytes
mscorlib.dll! System.Threading.ThreadPoolWorkQueue.Dispatch () + 0x1ea bytes
[Native resident of Managed Transition]
[appdomain transition]
[Native resident of Managed Transition]

It seems that my code has already returned the response.

When this happens then the next request is never handled, but after that one becomes normal.

What could be the reason for this behavior? I took a look at the source code for the CurrentModuleContainer.Get method and it seems that the only thing that can throw a tap pointer exception is the Http reference.

The exception can come from many different reasons, but one might guess that you have your handler, which is async Trying to use current HttpContext in the end can be nulled during the function.

Comments