The _________ class in ASP.NET Core Identity is particularly useful for creating and managing users.
- UserManager
- RoleManager
- AuthenticationService
- SecurityManager
The UserManager class in ASP.NET Core Identity is a vital component for creating, updating, and managing user accounts. It provides methods for tasks like creating users, assigning roles, and resetting passwords, making it an essential part of user management in ASP.NET Core applications.
The project.json file was prevalent in ASP.NET Core versions prior to _________.
- ASP.NET Core 1.0
- ASP.NET Core 2.0
- ASP.NET Core 3.1
- ASP.NET 4.0
The project.json file was used in ASP.NET Core 1.0, but it was replaced with a different project file format starting from ASP.NET Core 2.0.
To enable MVC in ASP.NET Core's Startup.cs, which method should be invoked inside the ConfigureServices method?
- services.AddMvc()
- services.UseMvc()
- services.ConfigureMvc()
- services.EnableMvc()
To enable MVC in ASP.NET Core, you should invoke the services.AddMvc() method inside the ConfigureServices method of the Startup.cs class. This method configures MVC services, such as routing, controllers, and view engines, making MVC available in your application.
How can you pass data from a controller to a Razor view?
- ViewBag
- ViewData
- TempData
- All of the above
You can pass data from a controller to a Razor view using multiple techniques, including ViewBag, ViewData, and TempData. These options allow you to share data between a controller and a view, but they have different lifetimes and use cases.
To extend the default user store in ASP.NET Core Identity, one would typically implement the _________ interface.
- IUserStore
- IIdentityStore
- ICustomStore
- IUserExtend
To extend the default user store in ASP.NET Core Identity, you would typically implement the IUserStore interface. This interface allows you to customize how user information is stored and managed. You can create a custom user store by implementing this interface and providing your own data storage mechanisms.
To avoid testing against the actual database, one might use a _________ database in integration testing.
- Mock
- In-memory
- NoSQL
- Distributed
To prevent integration tests from impacting the actual database, an in-memory database is often used. It simulates database behavior but operates entirely in memory, making tests faster and isolated. It's a common practice in ASP.NET Core testing.
When configuring ASP.NET Core Identity, the _________ class is used to specify policies like password strength and lockout duration.
- 'PolicySettings'
- 'AuthorizationOptions'
- 'IdentityOptions'
- 'SecurityPolicies'
When configuring ASP.NET Core Identity, the 'IdentityOptions' class is used to specify various settings, including policies like password strength and lockout duration. This class allows fine-grained control over the behavior of Identity.
One of the biggest advantages of ASP.NET Core over traditional ASP.NET is its ability to run on _________.
- Multiple Platforms
- Windows Only
- Linux Only
- macOS Only
One of the major advantages of ASP.NET Core is its ability to run on multiple platforms, including Windows, Linux, and macOS. This cross-platform compatibility provides greater flexibility in choosing the hosting environment for your ASP.NET Core applications.
In a situation where you're building a single-page application (SPA) with a default index.html, which middleware ensures that the file is served when a user accesses the root URL?
- UseDefaultFiles
- UseStaticFiles
- UseRouting
- UseEndpoints
The UseDefaultFiles middleware is used to serve default files, like index.html, when a user accesses the root URL of a web application. This middleware ensures that the SPA's default page is served correctly. Make sure to include app.UseDefaultFiles(); in your Configure method.
Your application uses ASP.NET Core Identity for authentication. During the security audit, it was pointed out that the application should enforce password reset every 90 days. How can you enforce this in ASP.NET Core?
- Configure password expiration in IdentityOptions
- Create a custom middleware to force password reset
- Implement a password reset policy in the login controller
- Use a third-party identity management library
To enforce password reset every 90 days in ASP.NET Core Identity, you should configure the password expiration policy in the IdentityOptions during application startup. This policy can be set to require users to change their passwords after a specified number of days.