title: Session State Not Available In This Context - In Global.asax
body: <p>I am getting a 'session state not available in this context' error.</p>
  
  <p><img src="https://i.stack.imgur.com/ihqyf.png" alt="enter image description here"></p>
  
  <p>The error is nested in the sender parameter of a number of methods within the Global.asax file:</p>
  
  <ul>
  <li>Application_BeginRequest</li>
  <li>Application_AuthenticateRequest</li>
  <li>Session_Start</li>
  <li>Application_Error</li>
  </ul>
  
  <p>The error happens on the very first page load (and all page loads thereafter).</p>
  
  <p>I've added a completely new and empty page, WebForm1.aspx, to the project and made it my start page.</p>
  
  <p>You'd think nothing could go wrong on an <strong>empty page</strong>. No code of mine is executed, as far as I can see, when loading an empty page. But I'm still getting the session state error.</p>
  
  <p>My project works totally fine. No error pages are shown. There is no incorrect behavior at any time.</p>
  
  <p>But the fact that this session error shows up in the sender parameter of my current project bugs me. This error is <strong>not</strong> generated in a blank, new project.</p>
  
  <p>What can possibly be the cause of this error in my current project?</p>
  
  <p>How can I trace where the error occurs? I can't set breakpoints in ASP.NET code that's <em>under the hood</em>. Or can I?</p>
  
  <p>Here's my session configuration:</p>
  
  <pre><code>&lt;pages enableSessionState="true" /&gt;
  &lt;sessionState mode="InProc" cookieless="false" timeout="20" /&gt;
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>I just found out that a brand new blank project also has this error in the sender object. It's visible in the Application_BeginRequest and Application_AuthenticateRequest methods. But the blank project isn't generating the Application_Error event, like my other project is.</p>