ASP.NET Core AuthorizeAttribute is just a marker containing a little data and no behavior (source). Whatever visits the attribute must contain the behavior.
What visits AuthorizeAttribute and what does it do?
ASP.NET Core AuthorizeAttribute is just a marker containing a little data and no behavior (source). Whatever visits the attribute must contain the behavior.
What visits AuthorizeAttribute and what does it do?
AuthorizeAttributeimplementedIAuthorizeDatainterfaceapp.UseAuthorization()middleware visitsAuthorizeAttributeFrom endpoint metadata accroding to the source code:then it could access the scheme,policy,roles you defined when you add the
AuthorizeattributeYou could try similar in a middleware:
Result: