Home > Blockchain >  Need advice of where to put custom user authorization in ASP.NET Core
Need advice of where to put custom user authorization in ASP.NET Core

Time:10-26

I need advice of where to put custom user authorization code in ASP.NET Core. I am somewhat a ASP.NET Framework developer and normally I will add code to Global.asax as a session_onstart event to look up a SQL table where users profile are stored that is used to determine what they can view in the rest of the application. With Global.asax this is only cause once per user session, so what I would like to do is the same kind of approach in ASP.NET Core which I am kind of new to but need advice where that check should be done

CodePudding user response:

I would like to do is the same kind of approach in ASP.NET Core which I am kind of new to but need advice where that check should be done

Well, based on your description, in asp.net core you can achieve that in many ways. For instances, you could set in following places:

  1. enter image description here

    You even can implement that using Middleware. Asp.net 6 now providing couple of other mechanism now a days, you could have a look below official implementations as well.

    1. Role-based authorization
    2. Claims-based authorization
    3. Policy-based authorization
    4. Custom Action Filter
  • Related