In complex scenarios, instead of using simple roles or claims, you might need a custom authorization policy. How do you apply a custom policy using the [Authorize] attribute?

  • [Authorize(Policy = "CustomPolicy")]
  • [Authorize("CustomPolicy")]
  • [Authorize(CustomPolicy)]
  • [Authorize(Roles = "CustomPolicy")]
To apply a custom authorization policy using the [Authorize] attribute, you should use the syntax [Authorize(Policy = "CustomPolicy")]. This tells ASP.NET Core to use the "CustomPolicy" when authorizing access to the action or controller.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *