Mixed Deck — All ASP.NET Core Topics Flashcards
100 cards from real ASP.NET Core practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 20 Mixed Deck — All ASP.NET Core Topics flashcards as text
What does [Area("Admin")] attribute do on a controller?
Answer: Associates the controller with the Admin routing area for URL organization
[Area] groups controllers into named areas, allowing separate folder structures and route namespaces like /admin/controller/action.
We need to obtain ______object from IoC container to create logs in an ASP.NET Core application.
Answer: ILogger
Explanation: ILogger and ILoggerFactory were added in.NET Core to provide a layer of abstraction for developers to use when adding logging to their applications. To record messages from the logging abstraction, the application can choose from a number of logging providers. These can save log messages in a variety of file formats, include extra information (such as the machine name), or transfer the messages to a log server for storage.
What exactly does ViewResult() imply?
Answer: It is a Concrete Class
Explanation: The ViewResult sends HTML to the client using the view engine as a response. With ASP.NET core, you can utilize a variety of view engines, although the razor view engine is the most popular. You can also build your own view engine. The ViewResult returns a view that includes or excludes data. Model binding can be used to pass data. The View is a physical file on the file system with the extension.cshtml or.vbhtml.
The ASP.NET core web application's host is set up in the________ file.
Answer: Program.cs
Explanation: The application begins at Program.cs. The Program.cs file will behave similarly to the Program.cs file in a traditional.NET Framework console application. The Program.cs file is the application's entry point, and it will be responsible for registering Startup.cs, IISIntegration, and the Main method's Create a host using an instance of IWebHostBuilder.
How do you configure a one-to-many relationship in EF Core Fluent API?
Answer: HasMany().WithOne()
HasMany().WithOne() defines a one-to-many relationship, with HasMany on the principal and WithOne on the dependent side.
Which route constraint restricts a route parameter to integer values only?
Answer: {id:int}
The :int route constraint ensures the segment matches only integer values, rejecting non-numeric requests at routing time.
What is the default hierarchy of configuration providers in ASP.NET Core?
Answer: appsettings.json → appsettings.{Env}.json → Environment variables → Command-line (last wins)
Later providers override earlier ones: appsettings.json → environment-specific file → env vars → command-line args.
What is the purpose of [HttpGet("{id}")] on an action method?
Answer: It constrains the action to GET requests and captures an 'id' route parameter
Combining the HTTP method attribute with a template restricts the HTTP verb and defines the route in one declaration.
Which interface provides configuration that reloads when the source file changes?
Answer: IOptionsMonitor
IOptionsMonitor is a singleton that fires a change notification and provides the latest configuration when the source changes.
Which configuration provider is used to read from Azure Key Vault?
Answer: Azure.Extensions.AspNetCore.Configuration.Secrets
The Azure.Extensions.AspNetCore.Configuration.Secrets NuGet package provides the AzureKeyVaultConfigurationProvider for reading secrets from Azure Key Vault.
To serve static files in an ASP.NET Core application, which middleware must be installed?
Answer: Microsoft.AspNetCore.StaticFiles
Explanation: To support static resources, an ASP.NET Core Application's application request processing pipeline must be configured with a middleware called UseStaticFiles (). The UseStaticFiles () middleware is an ASP.NET Core Framework intrinsic middleware that handles static files in an ASP.NET Core Application.
Which EF Core method retrieves an entity by its primary key from the DbContext?
Answer: FindAsync()
FindAsync() checks the local cache first before querying the database, returning null if not found.
How is scope validation enabled in ASP.NET Core DI to detect captive dependencies?
Answer: Set ValidateScopes = true in ServiceProviderOptions
Setting ValidateScopes = true (default in Development) causes the container to throw when a captive dependency is detected.
What is constructor injection in ASP.NET Core DI?
Answer: Declaring dependencies as constructor parameters that the DI container resolves automatically
Constructor injection is the primary DI pattern where ASP.NET Core resolves and passes dependencies automatically when creating the class.
Which NuGet package provides structured logging with Serilog in ASP.NET Core?
Answer: Serilog.AspNetCore
Serilog.AspNetCore integrates Serilog as the logging provider, replacing the default Microsoft logging pipeline.
What does [Bind] attribute do on a model class in ASP.NET Core MVC?
Answer: Restricts which properties are included during model binding
[Bind("Prop1,Prop2")] whitelists only the specified properties, preventing over-posting security vulnerabilities.
What is the file extension for a Razor Page's code-behind PageModel file?
Answer: .cshtml.cs
The PageModel code-behind uses the .cshtml.cs extension, pairing it with the corresponding .cshtml view file.
Which class is the base for custom authorization requirements in ASP.NET Core?
Answer: IAuthorizationRequirement
IAuthorizationRequirement is a marker interface implemented by requirement classes used in custom authorization policies.
What does calling @RenderBody() inside a Razor Layout page accomplish?
Answer: It inserts the content page's HTML at that location within the layout
@RenderBody() is the placeholder in a layout where the child content page's unique HTML markup is rendered.
What is the role of the IApplicationBuilder interface in ASP.NET Core?
Answer: It configures the request processing pipeline
IApplicationBuilder provides methods like Use, Run, and Map to compose the middleware pipeline.