If you need to add custom claims to a user during the registration process, which class or method in ASP.NET Core would you leverage?

  • UserManager class
  • ClaimsPrincipal class
  • IdentityUser class
  • IdentityRole class
You would leverage the UserManager class in ASP.NET Core Identity to add custom claims to a user during the registration process. The UserManager provides methods to manage and manipulate user-related data, including adding claims.

You're new to ASP.NET Core MVC and are wondering where to place the HTML files you've designed for your application. In a default MVC project structure, where should these files go?

  • Views
  • Models
  • Controllers
  • Middleware
In a default ASP.NET Core MVC project structure, HTML files should be placed in the 'Views' folder. The 'Views' folder contains the user interface components of your application, including HTML templates that are rendered to generate web pages.

When you want to share common Razor directives across multiple views, you would typically use the _______ file.

  • _ViewImports.cshtml
  • _Layout.cshtml
  • _ViewStart.cshtml
  • _Shared.cshtml
The correct file to share common Razor directives across multiple views is the "_ViewImports.cshtml" file. It allows you to define namespaces, tag helpers, and other common configurations that should apply to multiple views.

Your team is developing an audit system where every database update or insert should include a timestamp. However, you don't want to include this property in your entity classes. How would you implement this in Entity Framework Core?

  • Use Shadow Properties
  • Create a Separate Audit Table
  • Use Triggers
  • Add Timestamp Property to Entity Classes
To achieve this without including the timestamp property in your entity classes, you can use Shadow Properties in Entity Framework Core. Shadow properties are properties that are not defined in your entity classes but are tracked by EF Core for specific purposes like auditing.

Which file extension is commonly associated with Razor views?

  • .cshtml
  • .html
  • .aspx
  • .php
Razor views in ASP.NET Core typically have the ".cshtml" file extension. This extension signifies that the view contains both HTML markup and C# code, making it easy to create dynamic web pages that can interact with server-side data and logic.

You're working on a .NET project with a team and want to ensure everyone uses the same .NET SDK version. What file, when added to your project, can specify the SDK version developers should use?

  • .editorconfig
  • global.json
  • project.json
  • .NETVersion.json
To specify the SDK version for a .NET project, you should add a global.json file to the project directory. This file allows you to pin the SDK version, ensuring that all team members use the same version, promoting consistency in the development environment.

How do integration tests in ASP.NET Core typically differ from end-to-end tests in terms of scope and coverage?

  • Integration tests focus on testing the interaction between individual components of an application, while end-to-end tests assess the entire application's functionality.
  • Integration tests target specific modules within an application, whereas end-to-end tests only check the UI.
  • Integration tests are faster to execute than end-to-end tests.
  • Integration tests are automated, while end-to-end tests are manual.
Integration tests in ASP.NET Core usually concentrate on assessing the interaction and integration between various components, such as database interactions, service integrations, or API calls, within the application. In contrast, end-to-end tests evaluate the application's complete functionality, including its user interface, as if a user were interacting with it.

What is the role of Shadow Properties in Entity Framework Core?

  • They are properties with no corresponding database column
  • They are properties that store passwords securely
  • They are used for shadowing database tables
  • They are navigation properties in EF Core
Shadow Properties in EF Core are properties that are not part of the entity class's public API and have no corresponding database column. They are used internally by EF Core to store additional data or perform certain tasks, such as storing foreign key values or tracking change state.

In ASP.NET Core, which middleware is used to serve static files?

  • StaticFileMiddleware
  • AuthenticationMiddleware
  • DatabaseMiddleware
  • RoutingMiddleware
In ASP.NET Core, the StaticFileMiddleware is used to serve static files such as CSS, JavaScript, images, and other client-side assets. It's a crucial part of building web applications as it ensures that these files are accessible to the client's web browser.

When creating custom exception middleware in ASP.NET Core, which method should be overridden to handle the incoming HTTP request?

  • InvokeAsync
  • HandleError
  • OnException
  • ProcessRequest
When creating custom exception middleware in ASP.NET Core, you should override the InvokeAsync method. This method allows you to intercept and handle exceptions that occur during the processing of an incoming HTTP request, providing an opportunity to customize error responses or perform other actions.