You've just installed Visual Studio for ASP.NET Core development. Which tool should you ensure is also installed to help with command-line tasks for your projects?

  • .NET CLI
  • Docker
  • Git
  • Node.js
To perform command-line tasks in ASP.NET Core projects, you should ensure that the .NET CLI (Command Line Interface) is installed. It provides a set of commands for building, running, testing, and publishing ASP.NET Core applications.

Which HTTP status code is commonly associated with a server error caused by an unhandled exception in a web application?

  • 404 - Not Found
  • 200 - OK
  • 500 - Internal Server Error
  • 401 - Unauthorized
A server error caused by an unhandled exception in a web application is commonly associated with the HTTP status code 500 - Internal Server Error. This code indicates that an unexpected error occurred on the server, and it's a general indicator of a problem on the server side.

The @ViewData object is a type of _________, allowing you to pass data from the controller to the view.

  • Dictionary
  • List
  • Class
  • Interface
The @ViewData object is a type of Dictionary in ASP.NET Core. It is used to pass data from the controller to the view. ViewData allows you to share data between different parts of your application, making it available for rendering in the view.

What is the primary difference between the Process and ProcessAsync methods when defining a custom Tag Helper?

  • Process is synchronous, while ProcessAsync is asynchronous
  • Process is for server-side processing, while ProcessAsync is for client-side processing
  • Process can only be used in ASP.NET Core, while ProcessAsync is for ASP.NET Framework
  • Process is used for tag rendering, while ProcessAsync is for tag parsing
The primary difference between the Process and ProcessAsync methods in custom Tag Helpers is that Process is synchronous, while ProcessAsync is asynchronous. Process is used for synchronous processing and tag rendering, whereas ProcessAsync is employed for asynchronous operations, such as waiting for external data or I/O operations, which is important for responsiveness in modern web applications.

You're building a web application that requires different user roles like "Admin," "User," and "Guest." Using ASP.NET Core Identity, how would you restrict access to certain pages only for the "Admin" role?

  • Use [Authorize(Roles = "Admin")] attribute on the controller or action method
  • Use [Authorize(Policy = "AdminPolicy")] attribute with a custom policy
  • Use [Authorize("Admin")] attribute
  • Use [AllowAnonymous] attribute for "Guest"
To restrict access to specific pages for the "Admin" role, you should use the [Authorize(Roles = "Admin")] attribute. This attribute allows only users with the "Admin" role to access the decorated controller or action method.

What is the significance of the @model directive in a Razor view?

  • Specifies the layout of the view
  • Defines the model class for the view
  • Imports external libraries
  • Declares a variable
The @model directive in a Razor view specifies the model class that the view expects to receive. It allows you to strongly type the view, enabling compile-time checking and intellisense for model properties in the view. This helps prevent runtime errors and improves code maintainability.