You're new to ASP.NET Core and are confused about where to specify the common design elements (like headers and footers) that appear on every page. Which Razor concept should you explore for this purpose?

  • ViewComponents
  • Razor Layouts
  • Partial Views
  • Tag Helpers
To specify common design elements like headers and footers that appear on every page, you should explore Razor Layouts. Razor Layouts allow you to define a shared layout for your views, enabling you to encapsulate these common elements.

How can you define a route in ASP.NET Core to be available only for specific HTTP methods using attribute routing?

  • [HttpPut], [HttpPost]
  • [HttpGet], [HttpPost]
  • [HttpDelete], [HttpGet]
  • [HttpPatch], [HttpPut]
In ASP.NET Core, you can specify the HTTP methods a route should be available for using attributes like [HttpGet] or [HttpPost] above the controller action method. For example, [HttpGet] ensures the route is available for HTTP GET requests, and [HttpPost] for HTTP POST requests.

You have a page in your application that should be accessible to both authenticated and non-authenticated users. How do you configure this in ASP.NET Core?

  • Use [AllowAnonymous] attribute on the controller or action
  • Create separate pages for authenticated and non-authenticated users
  • Set up two different domains for each user type
  • Use cookies to track user access
To make a page accessible to both authenticated and non-authenticated users in ASP.NET Core, you can use the [AllowAnonymous] attribute on the controller or action that corresponds to the page. This attribute allows both types of users to access the page without requiring authentication.

What is the primary purpose of migrations in the context of ASP.NET Core Identity?

  • Define database schema for user-related data
  • Control user authentication
  • Handle user authorization
  • Manage user sessions
Migrations in ASP.NET Core Identity are primarily used to define and manage the database schema for user-related data. They allow you to create, update, and evolve the database structure to accommodate changes in your Identity-related models and requirements.

Which method is used to add MVC route handlers and specify the use of default routes?

  • AddMvc
  • UseRouting
  • UseEndpoints
  • MapRoute
In ASP.NET Core, the AddMvc method is used to add MVC route handlers and configure the use of default routes. This method sets up MVC services, including routing, and is essential for building web applications with ASP.NET Core MVC. It's typically called within the Startup class's ConfigureServices method.

To enforce a consistent structure and look across multiple views, developers use a ________ page in Razor.

  • Master
  • Index
  • Layout
  • Partial
To enforce a consistent structure and look across multiple views, developers use a Layout page in Razor. Layout pages define the common structure, such as headers and footers, shared across multiple views, ensuring a cohesive design.

When securing ASP.NET Core applications, the ________ attribute can be applied to ensure certain actions or controllers are accessible only to authenticated users.

  • [Authorize]
  • [AllowAnonymous]
  • [RequireHttps]
  • [ValidateAntiForgeryToken]
The [Authorize] attribute in ASP.NET Core is used to secure actions or controllers by specifying that only authenticated users are allowed access. It is a fundamental part of ASP.NET Core's security infrastructure.

Which method is typically used to sign a user out in ASP.NET Core?

  • Logout()
  • SignOut()
  • TerminateSession()
  • Disconnect()
The typical method used to sign a user out in ASP.NET Core is SignOut(). It clears the user's authentication cookies or tokens, effectively ending their authenticated session.

Which feature of ASP.NET Core allows real-time communication between the server and connected clients?

  • SignalR
  • RESTful APIs
  • WebSockets
  • gRPC
SignalR is a library in ASP.NET Core that enables real-time communication between the server and connected clients. It allows for features like chat applications, live notifications, and collaborative experiences in web applications. SignalR uses WebSockets when available but falls back to other techniques like long polling for broader compatibility.

Which tool can you use to create a new ASP.NET Core project?

  • Visual Studio, Eclipse, Xcode, Android Studio
  • Visual Studio Code, IntelliJ IDEA, NetBeans, PyCharm
  • Sublime Text, Atom, Brackets, Notepad++
  • All of the above
You can use Visual Studio, a popular integrated development environment (IDE), to create a new ASP.NET Core project. Visual Studio provides a rich set of features for .NET development, making it a preferred choice for many developers. Other IDEs like Eclipse, Xcode, and Android Studio are not typically used for ASP.NET Core development.