For projects focused on background tasks and might run as Windows services or Linux daemons, you should use the ________ template.

  • Worker
  • Web API
  • Blazor
  • MVC
The Worker template in ASP.NET Core is specifically designed for projects that focus on background tasks. It's ideal for creating services that perform work in the background and can be run as Windows services or Linux daemons. This template provides the necessary infrastructure for background task execution.

What's the main difference between using Database.EnsureCreated() and Migrations in Entity Framework Core?

  • Database.EnsureCreated() creates a database if it doesn't exist, ignoring migrations
  • Migrations allow for version control and tracking of database schema changes
  • Database.EnsureCreated() is used for unit testing only
  • Migrations are slower than EnsureCreated()
The main difference is that Database.EnsureCreated() creates a database without tracking schema changes, often used for development or unit testing, whereas migrations provide version control for your database schema, allowing you to apply, rollback, and manage changes over time.

Continuous _________ is a software development practice where changes in the code are automatically tested and prepared for a release to production.

  • Integration
  • Deployment
  • Testing
  • Delivery
Continuous Delivery is a software development practice where changes are automatically tested and prepared for release to production. It includes automated testing, deployment, and delivery of code changes.

For a Web API, you're required to ensure that only authenticated users can access specific endpoints, but some endpoints should be public. How would you achieve this in ASP.NET Core?

  • Use Authentication Filters
  • Use Authorization Filters
  • Configure Middleware
  • Use Role-Based Authorization
To control access to specific endpoints in an ASP.NET Core Web API, you'd use Authorization Filters. You can apply policies to controllers or actions, and these filters can determine whether a user is authorized to access the resource based on their identity and role. To make some endpoints public, you can use AllowAnonymous attribute or configure policies accordingly.

Which template should you choose when you need both Razor-based web pages and API controllers?

  • Web Application
  • Web API
  • Empty
  • Blazor
The "Web Application" template is the suitable choice when you need both Razor-based web pages for user interfaces and API controllers for handling data interactions. This template provides a balanced setup for creating web applications that combine server-rendered Razor pages with APIs for data exchange.

You are building a blog application where only the blog author should be able to edit or delete a post. How would you use the [Authorize] attribute to achieve this behavior?

  • Apply [Authorize] to the Edit and Delete actions
  • Apply [Authorize] to the entire controller
  • Use [Authorize(Roles = "Admin")] for blog authors
  • Use [AllowAnonymous] for blog authors
To ensure that only the blog author can edit or delete a post, you would apply the [Authorize] attribute to the Edit and Delete actions in the controller. This allows you to specify authorization at the action level, and you can further customize it to check if the user making the request is the author of the post being edited or deleted. Applying [Authorize] to the entire controller would restrict access to all actions within it, which is not the desired behavior in this case. [Authorize(Roles = "Admin")] is role-based authorization and doesn't address this scenario, and [AllowAnonymous] would allow everyone, which is the opposite of the desired behavior.

In a CI/CD pipeline for an ASP.NET Core application, after the code is committed to a version control system, what is typically the next step?

  • Build
  • Manual Testing
  • Deployment
  • Documentation
After code is committed to a version control system (e.g., Git), the next typical step in a CI/CD (Continuous Integration/Continuous Deployment) pipeline is the build process. During the build, the code is compiled, tested, and packaged, preparing it for deployment to different environments.

Your ASP.NET Core application has a scenario where a user tries to update a record that another user has already modified. How can you handle such scenarios using Entity Framework Core to ensure data integrity?

  • Optimistic Concurrency
  • Pessimistic Locking
  • No Locking
  • Dirty Read
Optimistic Concurrency is a technique used in Entity Framework Core to handle concurrent updates. When enabled, it checks if a record has been modified by another user since it was loaded, and if so, it prevents the update, ensuring data integrity and preventing data loss due to overwrites.

When deploying an ASP.NET Core application using Docker, which file is crucial for defining the environment and settings of the container?

  • Dockerfile
  • appsettings.json
  • Startup.cs
  • Package.json
The crucial file for defining the environment and settings of a Docker container for an ASP.NET Core application is the Dockerfile. This file contains instructions on how to build the container image, what base image to use, and how to configure the environment.

For ensuring that the test runs in isolation, real services or components might be replaced with _________ during unit testing.

  • Mocks
  • Stubs
  • Dummies
  • Fakes
During unit testing, real services or components that are external to the unit being tested are often replaced with mocks or stubs. Mocks provide controlled behavior for testing without relying on the actual implementations of these external components.