For a Web API, you're required to ensure that only authenticated users can access specific endpoints, but some endpoints should be public. How would you achieve this in ASP.NET Core?

  • Use Authentication Filters
  • Use Authorization Filters
  • Configure Middleware
  • Use Role-Based Authorization
To control access to specific endpoints in an ASP.NET Core Web API, you'd use Authorization Filters. You can apply policies to controllers or actions, and these filters can determine whether a user is authorized to access the resource based on their identity and role. To make some endpoints public, you can use AllowAnonymous attribute or configure policies accordingly.
Add your answer
Loading...

Leave a comment

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