title: Store temporarily custom windows authentication roles
body: <p>I have a MVC4 project in which I implemented custom windows authentication following this <a href="https://stackoverflow.com/questions/9018222/extending-windows-authentication-in-asp-net-mvc-3-application">question</a>.</p>
  
  <p>Everything is working fine, I created my roles database and so on. The thing is that I want to store temporarily the roles into Session Variable because almost every controller's action have an Authentication Attribute so every authentication request would hit the database, and I don't want that. </p>
  
  <p>All the magic happens in Application_AuthenticateRequest</p>
  
  <pre><code>protected void Application_AuthenticateRequest(object sender, EventArgs e)
      {
          if (Request.IsAuthenticated)
          {
              WindowsIdentity wi = (WindowsIdentity)HttpContext.Current.User.Identity;
              CustomPrincipal mp = new CustomPrincipal(wi);
              HttpContext.Current.User = mp;
          }
  
      }
  </code></pre>
  
  <p>In that event HttpContext.Session is not available (yet) but every request hit this event before anything else.</p>
  
  <p>I want to store the roles session based, Is there a way to do that or I have to implement authentication cookie in order to achieve that?</p>
  
  <p>Thank you!</p>