Which feature in ASP.NET Core Identity is used to specify the minimum length for user passwords?

  • Password Requirements
  • Account Lockout
  • Two-Factor Authentication
  • Role-Based Authorization
ASP.NET Core Identity provides the "Password Requirements" feature to specify criteria for user passwords, including the minimum length. This is essential for enforcing security standards, and developers can configure it as needed in their applications.

Which of the following tools is NOT typically used for ASP.NET Core development?

  • Eclipse
  • Rider
  • Visual Studio
  • Visual Studio Code
While Eclipse is a powerful IDE mostly known for Java development and other types of development, it's not typically used for ASP.NET Core development. Tools like Visual Studio, Visual Studio Code, and Rider provide integrated support for ASP.NET Core.

If you wish to apply a unique constraint on a column using the Fluent API in Entity Framework Core, which method should you use inside OnModelCreating?

  • HasIndex
  • HasUniqueConstraint
  • IsUnique
  • SetUnique
To apply a unique constraint on a column in Entity Framework Core using the Fluent API, you should use the IsUnique method. This method ensures that the database enforces uniqueness for the specified column or columns, preventing duplicate values from being inserted. It's a crucial feature for maintaining data integrity.

The [______] attribute in ASP.NET Core is used to specify the route template for an action method.

  • Route
  • HttpPost
  • Authorize
  • ValidateAntiForgeryToken
In ASP.NET Core, the [Route] attribute is used to define the route template for an action method. This template determines how the URL should be structured to access the method. For example, [Route("api/products")] specifies that the method should be reachable at the URL "api/products."

After a user logs into your application, you want to display a personalized greeting like "Welcome, [Username]!". How can you fetch the username of the currently logged-in user in ASP.NET Core?

  • Use HttpContext.User.Identity.Name
  • Query the database for the username
  • Prompt the user to enter their username after login
  • Use a hardcoded username
In ASP.NET Core, you can fetch the username of the currently logged-in user by accessing HttpContext.User.Identity.Name. This property contains the username of the authenticated user, allowing you to display a personalized greeting like "Welcome, [Username]!".

What is the primary purpose of the [Authorize] attribute in ASP.NET Core?

  • Authentication
  • Authorization
  • Caching
  • Logging
The [Authorize] attribute in ASP.NET Core is primarily used for Authorization, not Authentication. It restricts access to a particular action method or controller to only authenticated users who meet specific authorization requirements. This helps in controlling who can access different parts of your application based on roles or policies.

When defining a one-to-many relationship in Entity Framework Core, which Fluent API method is commonly used to represent the "many" side?

  • HasOne
  • HasMany
  • WithOne
  • WithMany
When defining a one-to-many relationship in Entity Framework Core, the HasMany method is commonly used to represent the "many" side of the relationship. This method allows you to specify the navigation property on the "one" side and configure various aspects of the relationship, such as cascading deletes and foreign key constraints on the "many" side. It's an essential part of modeling complex database relationships.

The default convention in ASP.NET Core MVC looks for views in the _________ folder.

  • Views
  • Models
  • Controllers
  • Pages
In ASP.NET Core MVC, the default convention for locating views is in the "Views" folder within the project's directory structure. Views contain the markup and templates used to generate the HTML or other output sent to the client's browser.

Imagine you have two route templates: /products/{id} and /products/new. An incoming request has the URL /products/new. Which route will it match and why?

  • /products/{id}
  • /products/new
  • It will not match any route
  • /products/{action}
ASP.NET Core routing uses a first-match-wins strategy. In this case, the incoming request "/products/new" matches the second route "/products/new" exactly. Therefore, it will not proceed to check other routes and will be handled by the "/products/new" route.

The configuration values in __________ will override the values from appsettings.json when deploying an application to production.

  • appsettings.Development.json
  • launchSettings.json
  • appsettings.Production.json
  • appsettings.json
In ASP.NET Core, configuration settings can be stored in various JSON files, such as "appsettings.json" for general settings. However, when deploying to production, the configuration values in "appsettings.Production.json" take precedence over those in "appsettings.json." This allows developers to maintain separate configurations for different environments.