Custom Principal Caching in ASP.Net
<p>I am successfully working with a custom principal in ASP.NET, but my custom principal loads database data and I don't want that happening on every request into the system.</p>

<p>I load my custom principal in the Global.ascx file in the Application_OnPostAuthenticateRequest, but it appears session state is not available here.  Where am I suppose to stick it after the first request into the system so that I don't have to keep recreating it from scratch?</p>

<pre><code> protected void Application_OnPostAuthenticateRequest(Object sender, EventArgs e)
        {
            IPrincipal principal = HttpContext.Current.User;

            if(principal.Identity.IsAuthenticated == true &amp;&amp; principal.Identity.AuthenticationType == "Federation")
            {
                CustomPrincipal customPrincipal = null;


                    IClaimsPrincipal claimsPrincipal = (IClaimsPrincipal)principal;

                    if (claimsPrincipal == null)
                    {
                        throw new ApplicationException("We should have a claims principal at this point");
                    }

                    customPrincipal = new CustomPrincipal(claimsPrincipal);


                HttpContext.Current.User = customPrincipal;
                Thread.CurrentPrincipal = customPrincipal;

            }
        }
</code></pre>
