How to create a CustomPrincipal globally (with and without AuthorizeAttribute)

后端 未结 2 1067
抹茶落季
抹茶落季 2020-12-13 11:24

I have a custom Principal/Identity for my ASP.NET MVC4 web app. I have also created a AuthorizeAttribute to instantiate my custom principal, assigning it to httpContext.User

2条回答
  •  情话喂你
    2020-12-13 12:22

    Overridding Principal in:

    protected void Application_PostAuthenticateRequest(object sender, EventArgs e)
    

    Instead of

    protected void Application_AuthenticateRequest(object sender, EventArgs e)
    

    In Global.asax.cs worked for me in an ASP web application

提交回复
热议问题