I have been dealing with this sneaky exception for a while, and I'm having a very hard time figuring it out. When a session expires or when I call Session.Abandon() the application will run for a second and then Visual studio will tell me it is in a break mode and will stop the debugging. When this happens on our production server it will kill the application pool. The project is a .Net webforms application running on .Net 4.5.2.
I've tried stepping through all the code after calling Session.Abandon() and it will throw the exception on random places.
The stack trace:
Exception: System.Web.HttpException
Message: Exception of type 'System.Web.HttpException' was thrown.
StackTrace: at System.Web.HttpAsyncResult.End()
at System.Web.Util.AspCompatApplicationStep.RaiseAspCompatEvent(HttpContext context, HttpApplication app, String sessionId, EventHandler eventHandler, Object source, EventArgs eventArgs)
at System.Web.HttpApplicationFactory.FireSessionOnEnd(HttpSessionState session, Object eventSource, EventArgs eventArgs)
at System.Web.SessionState.SessionOnEndTargetWorkItem.RaiseOnEndCallback()
at System.Web.Util.WorkItem.CallCallbackWithAssert(WorkItemCallback callback)
at System.Web.Util.WorkItem.OnQueueUserWorkItemCompletion(Object state)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
InnerException: System.ArgumentNullException
Message: Value cannot be null.
Parameter name: httpContext
StackTrace: at System.Web.HttpContextWrapper..ctor(HttpContext httpContext)
at System.Web.HttpApplication.<>c__DisplayClass284_0.<OnExecuteRequestStep>b__0(Action nextStepAction)
at System.Web.HttpApplication.StepInvoker.Invoke(Action executionStep)
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
All help is greatly appreciated!