title: Set session variable in Application_BeginRequest
body: <p>I'm using ASP.NET MVC and I need to set a session variable at <code>Application_BeginRequest</code>. The problem is that at this point the object <code>HttpContext.Current.Session</code> is always <code>null</code>. </p>
  
  <pre><code>protected void Application_BeginRequest(Object sender, EventArgs e)
  {
      if (HttpContext.Current.Session != null)
      {
          //this code is never executed, current session is always null
          HttpContext.Current.Session.Add("__MySessionVariable", new object());
      }
  }
  </code></pre>