You've been asked to create a new website for your company's marketing team. Which ASP.NET Core template would be a good starting point for a site with static pages?

  • Razor Pages
  • Empty
  • Web API
  • MVC
Razor Pages is a great starting point for creating websites with static pages. It's a lightweight framework in ASP.NET Core designed for creating web pages without the complexities of full MVC. Razor Pages allow you to build simple, static web pages efficiently.

Which feature in ASP.NET Core Identity helps to manage user roles and claims?

  • Role-Based Authorization
  • IdentityServer4
  • Token Authentication
  • Swagger UI
Role-Based Authorization is a key feature of ASP.NET Core Identity that allows you to manage user roles and claims. It enables fine-grained access control by associating users with specific roles and defining role-based policies for authorization.

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?

  • .gitignore
  • README.md
  • global.json
  • package.json
To specify the SDK version for a .NET project, you should add a "global.json" file to the project's root directory. This JSON file allows you to define the desired SDK version, ensuring consistency among team members and across development environments.

What file extension is commonly associated with Razor views?

  • .html
  • .cshtml
  • .js
  • .css
Razor views in ASP.NET Core commonly use the file extension ".cshtml." This extension indicates that the file contains both HTML markup and C# or VB.NET code, which can be executed on the server to generate dynamic web content.

To execute raw SQL queries in Entity Framework Core, developers can utilize the _________ method.

  • FromSqlRaw
  • ExecuteSql
  • ExecuteRawSql
  • ExecuteSqlCommand
Developers can utilize the "FromSqlRaw" method in Entity Framework Core to execute raw SQL queries. This method allows you to execute SQL queries directly and map the results to entity types. It's particularly useful when you need to work with complex queries or call stored procedures.

Which folder in an ASP.NET Core project typically contains static files like images, CSS, and JavaScript?

  • Models
  • Controllers
  • Views
  • wwwroot
In an ASP.NET Core project, static files like images, CSS, and JavaScript are typically stored in the "wwwroot" folder. This folder serves as a root for serving static web assets to clients. Placing static files here ensures they can be accessed directly via a web browser, enhancing the performance of your web application.

While working on an MVC project, you realize the need to pass both the product details and a list of related reviews to a view. How might you best structure your data to achieve this?

  • Use a ViewModel to combine product details and reviews
  • Pass product details as ViewBag and reviews as ViewData
  • Use a Tuple to combine product details and reviews
  • Embed reviews as a JSON object within the product details
To pass both product details and a list of related reviews to a view, it's best to use a ViewModel. A ViewModel is a dedicated class that combines the necessary data for a view. This approach keeps your code clean, maintainable, and allows for strong typing in your view.

When creating custom constraints for routing, developers need to implement the _______ interface.

  • IRouteHandler
  • IRouteConstraint
  • RouteBase
  • RouteHandler
When you need to create custom constraints for routing in ASP.NET Core, you should implement the IRouteConstraint interface. This interface allows you to define your custom logic to determine if a route is a match or not, providing flexibility in routing scenarios.

How does the ASP.NET Core MVC determine which controller and action to route a request to?

  • Through URL Routing
  • By Checking File Names
  • By Request Header
  • Through a Random Process
ASP.NET Core MVC determines the controller and action to route a request to through URL routing. The routing system maps incoming URLs to controller actions based on predefined route patterns, allowing for a clean and user-friendly URL structure in your web application.

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.