You're building an application where some static files need to be accessible only for authenticated users. How might you achieve this in an ASP.NET Core application?
- UseStaticFiles
- UseAuthentication
- UseAuthorization
- UseRouting
To restrict access to static files for authenticated users, you should use the UseAuthorization middleware in combination with proper authorization policies. Configure your policy to allow access to these files only for authenticated users, ensuring that unauthorized users can't access them.
Loading...
Related Quiz
- You're noticing that despite having global exception handling set up in your ASP.NET Core application, certain exceptions aren't being caught. What might be a plausible reason for this behavior and how can you ensure all exceptions are captured?
- In an online quiz application, you want to ensure that only teachers can create or edit questions. Which attribute in ASP.NET Core will help you achieve this functionality?
- The _________ method of UserManager can be used to check if a user with a specific email address already exists.
- If you wanted to change the way request logging is done in an ASP.NET Core application, which file would you typically modify?
- You're reviewing a colleague's code and notice that they've added the same namespace to multiple Razor views. How can you suggest an optimization to this approach?