title: Call Async Method from Session_Start
body: <p>How can I call an <strong>async</strong> method from <code>Session_Start</code> in Global.asax ?</p>
  
  <p>Global.asax:</p>
  
  <pre><code>    protected async Task Session_Start(object sender, EventArgs e)
      {            
          Session.Timeout = 10;
  
          // Do some asynch work
          await repository.SetStatsInfo(System.DateTime.Now);            
      }
  </code></pre>
  
  <p>async method:</p>
  
  <pre><code>    public async Task SetStatsInfo(DateTime time)
      {
          using (ApplicationDBContext db = new ApplicationDBContext())
          {
              // Do stuff (update visitors counter in db) ..
  
              await db.SaveChangesAsync();
  
          }
      }
  </code></pre>
  
  <p>I can run it all synchronously (define <code>void Session_Start</code> etc.) which is working, but would prefer the async way so that hitting the db is not blocking.</p>
  
  <p>Running like this with 'async Task' for <code>Session_Start</code>, the code is not executed,
  breakpoints inside <code>session_start</code> are not hit.</p>