title: Event handlers can only be bound to HttpApplication events during IHttpModule initialization
body: <p>I am getting the following error </p>
  
  <p>'Event handlers can only be bound to HttpApplication events during IHttpModule initialization.' at the following code (line in bold or double **)</p>
  
  <pre><code>protected void Application_BeginRequest(object sender, EventArgs e)
  {
      HttpApplication app = (HttpApplication)sender;
      **app.EndRequest += new EventHandler(Application_EndRequest);**        
  }
  
  protected void Application_EndRequest(object sender, EventArgs e)
  {
      UnitOfWork.Commit();
  }
  </code></pre>
  
  <p>which is mentioned in Global.asax file. Can anybody figure out, where I am lacking? Thanks.</p>