You are developing a news portal where general articles are available for all, but exclusive content should be accessed only by subscribers. How would you ensure this using the [Authorize] attribute?
- Use [Authorize] attribute with a policy that checks for the user's subscription status.
- Create separate controllers for general and exclusive content, applying [Authorize] to the latter.
- Set up a custom middleware to handle access control based on user roles.
- Implement a client-side authentication mechanism using JavaScript.
To restrict access to exclusive content, you can use the [Authorize] attribute with a policy that checks for the user's subscription status. This policy can be configured to allow access only to authenticated users with a valid subscription.
Loading...
Related Quiz
- How can you specify a shadow property using the Fluent API in Entity Framework Core?
- What is the primary purpose of CI/CD in the context of software deployment?
- You have just started learning about ASP.NET Core MVC and came across the term "Routing." What is the primary purpose of routing in MVC applications?
- What do you use in Entity Framework Core to represent and configure the database tables and relationships?
- If you want to add user secrets in a development environment without affecting the main configuration files, which tool or method would you typically use in an ASP.NET Core project?