While looking into another problem I met a peculiar situation.
Within the Global.asax method I have the following code:
protected void Application_AcquireRequestState(object sender, EventArgs e)
{
if (!(Context.Handler is IRequiresSessionState || Context.Handler is IReadOnlySessionState)) // No session - no validation.
return;
DoSomething();
}
The DoSomething()
method call throws a NullReferenceException
and it is simple enough that the only place it could do that was if HttpContext.Current.Session
was null.
How can this be?