Which of the following best describes where you would apply the [Authorize] attribute?
- Above the class definition for global authorization
- Above the method that requires authorization
- Within the Startup.cs file
- In the web.config file
The [Authorize] attribute should be applied above the method that requires authorization. This means you place it directly above the action method within a controller where you want to restrict access. This approach allows for fine-grained control over which actions are protected and who can access them, ensuring security at the method level.
Loading...
Related Quiz
- What purpose does the .NET Core CLI serve in ASP.NET Core development?
- You're trying to locate your application's main CSS files in an ASP.NET Core project. In which directory would you typically find them?
- You are tasked to catch all unhandled exceptions globally in your ASP.NET Core MVC application. Which approach would be most suitable to achieve this?
- You've just started with ASP.NET Core and want to set up a new MVC project. Which tool or environment would you typically use to create this project?
- You've heard about two-factor authentication for enhancing security. How can ASP.NET Core Identity help in implementing this feature?