Your company's security policy dictates that users must change their passwords every 60 days. How would you implement this requirement using ASP.NET Core Identity?

  • Implement a custom middleware
  • Configure the Password Policy
  • Use a third-party authentication library
  • Manually reset passwords every 60 days
To enforce password change policies in ASP.NET Core Identity, you would configure the Password Policy settings. This includes setting options like PasswordExpiration, RequiredUniqueChars, and MinimumPasswordLength. By configuring these settings, you can enforce password changes every 60 days as per your company's security policy.

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.

How does the "Worker Service" template in ASP.NET Core differ from the traditional web application templates?

  • It focuses on client-side rendering.
  • It's designed for background processing tasks without HTTP endpoints.
  • It uses the Model-View-Controller (MVC) pattern.
  • It has a built-in database.
The "Worker Service" template in ASP.NET Core is tailored for background processing tasks, such as scheduled jobs, message processing, and other non-HTTP tasks. It doesn't include the typical web application features like HTTP endpoints, controllers, or views, making it ideal for scenarios where you don't need to handle HTTP requests.

Which file in an ASP.NET Core project typically contains project metadata, package dependencies, and project-specific settings?

  • Program.cs
  • Startup.cs
  • appsettings.json
  • project.json
The appsettings.json file in an ASP.NET Core project typically contains project metadata, package dependencies, and project-specific settings. It's a JSON configuration file used to store various configuration values for the application, such as database connection strings, logging settings, and custom application settings. This separation of configuration from code promotes flexibility and maintainability in ASP.NET Core applications.

What distinguishes the Kestrel web server in the ASP.NET Core ecosystem?

  • It's a Windows-exclusive web server
  • It's a cross-platform, lightweight, and high-performance web server
  • It's a reverse proxy server
  • It's used for database management
Kestrel is a distinctive component in the ASP.NET Core ecosystem because it's a cross-platform, lightweight, and high-performance web server. Unlike some other web servers that are platform-specific, Kestrel can run on Windows, Linux, and macOS, making it a preferred choice for ASP.NET Core hosting. It is often used in combination with reverse proxy servers like Nginx or IIS for production scenarios.