I am faced with a particularly interesting situation. I currently have a general error handling procedure. I recently noticed some strange behavior: HttpApplication.Error will fire, but HttpContext.Current will be empty. This is the corresponding bit in my HttpModule:
public void Init(HttpApplication context) { context.Error += context_Error; context.PostMapRequestHandler += context_PostMapRequestHandler; } void context_PostMapRequestHandler(object sender, EventArgs e) { var aux = HttpContext.Current.Handler as Page; if (aux != null) aux.Error += context_Error; } void context_Error(object sender, EventArgs e) { _localLog.Add("HttpApplication error handler reached."); try { if (HttpContext.Current == null) { _localLog.Add("No HttpContext."); } else { var objError = HttpContext.Current.Server.GetLastError(); if (objError == null) { _localLog.Add("GetLastError(): no error."); return; }
And an intriguing event would look like this:

My first assumption is that an exception is thrown into the thread out of context.
In any case, how can I lock it correctly?
OnoSendai
source share