MVC5 controllers have a User property which is a System.Security.Claims.ClaimsPrincipal
I've created a base controller which I inherit from. This base controller's User
property is overridden with mycustomPrinciple
which inherits from System.Security.Claims.ClaimsPrincipal
public abstract partial class BaseController : Controller
{
public new mycustomPrinciple User
{
get
{
return base.User as mycustomPrinciple; //returns null here
}
}
}
public class mycustomPrinciple : System.Security.Claims.ClaimsPrincipal
{
private int _ID;
public int ID
{
get { return _ID; }
set { _ID = value; }
}
}
as you can see above it fails on the cast. I'm unsure as to why this is as i did a similar thing in MVC4 but the inherited principle was System.Security.Principal.IPrincipal
as this is what the controllers User property was a type of.