I usually avoided the session state in proc until this recent project. I think I have a problem when the state is lost after an unhandled exception occurs.
This in itself is odd, because exceptions in the context of the request do not reset the workflow. It may be an exception in the background thread or callback, or something like that, but it is a simple site and nothing happens.
The session ID remains the same, and Session_Start is not called on a subsequent request (therefore, WP is not processed).
I have quite a bit of registration, and I see that I get an exception from the data layer, its HttpException inside the HttpUnhandleException, and then when I look right after the main page, the request logs a warning about the missing state.
Worse. This does not happen in my dev block (IIS Express), only in QA.
Edit:
Here is a snippet of the log:
2013-06-12 13:44:29,975 [23] FATAL MvcApplication 100.100.100.100 pxtgn GET An unhandled exception occurred in the web application. The full exception will be unrolled below. 2013-06-12 13:44:30,897 [23] FATAL MvcApplication 100.100.100.100 pxtgn GET Exception.Type: HttpUnhandledException Exception.Source: System.Web Exception.Message: Exception of type 'System.Web.HttpUnhandledException' was thrown. Exception.StackTrace: at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.HttpContext.InvokeCancellableCallback(WaitCallback callback, Object state) at System.Web.UI.Page.LegacyAsyncPageBeginProcessRequest(HttpContext context, AsyncCallback callback, Object extraData) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) Exception.Type: HttpException Exception.Source: CompanyNameProductName.MvcCoreApp Exception.Message: An error was reported by the data layer: 0Image not found1-10.1007_978-1-4471-4294-2_21-16 Exception.StackTrace: at CompanyName.CompanyNameProductName.imagedetail.Page_Load(Object sender, EventArgs e) in c:\DATA\Git\ProductName\CompanyNameProductNameMvc\imagedetail.aspx.cs:line 55 at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 2013-06-12 13:45:07,913 [25] DEBUG StandardPage 100.100.100.100 pxtgn GET Initializing page 'default_aspx' for GET with query string: 2013-06-12 13:45:07,913 [25] ERROR StandardPage 100.100.100.100 pxtgn GET No User instance in session state. Check the log for signs that the session was started properly since a User object should aways exist in session state, setup via session start events in ASP.NET.
The last line displays the state of the missing state. Pxtgn is the first 5 characters of the session identifier. I got to a page for which I know that the data level will depend on a nonexistent image id. Then any page that I hit will lead to the fact that my check will lead to the registration of a problem with a missing state. The check and status link is in the code of the main page, so I can go to any page to see the problem. It also means that the custom error page is not working - this is how I came to find the error.
Now I added Session.Abandon() after checking and answered 500 to get me out of jail, but this is a rather strange problem. I am new to the codebase and I think I checked all the information that the session is being cleared or overwritten.