How to get HttpContext.Current.User as custom principal in mvc c#
<p>I am trying to use the <code>HttpContext.Current.User</code> with my own class that inherits from <code>IPrincipal</code>. I am not exactly sure why..</p>

<pre><code>var lIdentity = new UserIdentity(lFormsTicket);
var lRoles = lAuthUser.Roles.Select(x =&gt; x.Role.ToString()).ToArray();
var lPrincipal = new GenericPrincipal(lIdentity, lRoles);

System.Web.HttpContext.Current.User = lIdentity;
</code></pre>

<p>Right after I am setting this it works. But if I do another request on the site, it says that it cannot cast it. Am I missing something here?</p>