In which order does ASP.NET Core execute middleware components?

  • Sequentially in the order they are added
  • Random order
  • Alphabetical order
  • In parallel
ASP.NET Core executes middleware components sequentially in the order they are added to the application's request pipeline. This order is significant because it determines the sequence of processing for incoming requests and outgoing responses as they pass through each middleware component.

The Output property of a custom tag helper, of type _______, allows you to manipulate the final output of the tag helper.

  • string
  • int
  • TagHelperContent
  • object
The Output property of a custom tag helper is of type TagHelperContent. It allows you to manipulate the final HTML output produced by the tag helper, giving you fine-grained control over the generated markup. You can append, prepend, or replace content within the HTML element.

How can you conditionally branch the middleware pipeline based on specific criteria, like a request path or a header value?

  • Use conditional statements within middleware
  • Add custom middleware for branching
  • Utilize the UseWhen method
  • Modify the request object directly
To conditionally branch the middleware pipeline, you can use the UseWhen method provided by ASP.NET Core. This method allows you to specify a condition, and based on that condition, you can choose whether to execute certain middleware components or not. It's a powerful way to customize the pipeline based on specific criteria.

In complex scenarios, instead of using simple roles or claims, you might need a custom authorization policy. How do you apply a custom policy using the [Authorize] attribute?

  • [Authorize(Policy = "CustomPolicy")]
  • [Authorize("CustomPolicy")]
  • [Authorize(CustomPolicy)]
  • [Authorize(Roles = "CustomPolicy")]
To apply a custom authorization policy using the [Authorize] attribute, you should use the syntax [Authorize(Policy = "CustomPolicy")]. This tells ASP.NET Core to use the "CustomPolicy" when authorizing access to the action or controller.

When you want to use a namespace across multiple Razor views without adding it to each view, where should you define it?

  • In the _ViewStart.cshtml file
  • In the _Layout.cshtml file
  • In the _ViewImports.cshtml file
  • In each individual Razor view
You should define a namespace that you want to use across multiple Razor views in the _ViewImports.cshtml file. This file is specifically designed to consolidate 'using' directives, making them accessible throughout the views that share it, thereby improving code organization and reusability.

In ASP.NET MVC, Master Pages have been replaced with _______ in Razor views.

  • Partial Views
  • Layout Pages
  • Helper Pages
  • Include Pages
In ASP.NET Core Razor views, Master Pages have been replaced with "Layout Pages." Layout Pages define the overall structure and common elements for views, similar to Master Pages in previous versions of ASP.NET. They provide a consistent layout for multiple views within your application.

Which part of the MVC pattern is primarily concerned with how the application's data is represented and manipulated?

  • Model
  • View
  • Controller
  • Middleware
In the MVC pattern, the Model is primarily concerned with how the application's data is represented and manipulated. It encapsulates the business logic, data storage, and interactions with the database. It acts as a bridge between the Controller and the View, providing the necessary data to be displayed.

After completing the development of a feature, you decide to run tests to ensure that your new code doesn't break existing functionality. What is this type of testing called?

  • Regression Testing
  • Performance Testing
  • Usability Testing
  • Smoke Testing
Running tests after developing a new feature to ensure that existing functionality remains unaffected is known as Regression Testing. It helps catch unintended side effects or bugs introduced by new code changes.

You've been asked to modify the configurations that get loaded during the startup of your ASP.NET Core application. Which file should you primarily focus on?

  • Startup.cs
  • appsettings.json
  • Program.cs
  • HomeController.cs
In an ASP.NET Core application, the Startup.cs file is where you primarily configure the application's services, middleware pipeline, and other startup-related settings. This is where you can modify how the application behaves during startup.

Which protocol does SignalR use primarily before falling back to other techniques?

  • WebSocket
  • HTTP
  • FTP
  • TCP
SignalR primarily uses the WebSocket protocol for real-time communication due to its low latency and bidirectional capabilities. WebSocket provides a full-duplex communication channel, making it ideal for applications requiring instant updates. SignalR gracefully falls back to other techniques like HTTP long polling or Server-Sent Events for compatibility with older browsers or network restrictions.