What is ASP.NET Core?
ASP.NET Core is Microsoft's cross-platform, open-source framework for building modern web applications, REST APIs, real-time applications, and backend services on .NET.
ASP.NET Core interview questions covering asp.net core fundamentals.
Open a question for the full answer, code and interview guidance.
ASP.NET Core is Microsoft's cross-platform, open-source framework for building modern web applications, REST APIs, real-time applications, and backend services on .NET.
Major advantages include cross-platform support, high performance, open-source development, a modular architecture, built-in dependency injection, unified configuration and logging, and first-class support for cloud and container deployments.
ASP.NET Core is cross-platform and runs on modern .NET, whereas classic ASP.NET Framework is primarily Windows-based and tightly coupled to the .NET Framework and System.Web.
Program.cs is the application entry point. In the modern hosting model, it creates the WebApplicationBuilder, registers services in the dependency injection container, builds the application, configures the HTTP request pipeline, maps endpoints, and starts the application.
WebApplicationBuilder is the object used to configure an ASP.NET Core application before it is built. It exposes configuration, logging, environment information, host settings, and the IServiceCollection used for dependency injection.
WebApplication represents the configured ASP.NET Core application after WebApplicationBuilder.Build() is called. It implements the application host and provides methods for configuring middleware and mapping endpoints.
The request pipeline is the ordered sequence of middleware components through which each HTTP request and response passes.
Middleware is software assembled into the HTTP pipeline to handle requests and responses. Each middleware component typically receives an HttpContext and a RequestDelegate representing the next component in the pipeline.
Kestrel is the cross-platform web server used by ASP.NET Core. It listens for HTTP requests and hosts the application's HTTP pipeline.
A reverse proxy is a server that receives client requests and forwards them to the ASP.NET Core application, usually running on Kestrel.
Dependency injection is a design technique in which a class receives the services it depends on instead of constructing those services itself. ASP.NET Core includes a built-in dependency injection container.
Transient services are created each time they are requested. They are suitable for lightweight, stateless services.
IServiceCollection is the collection used to register services with ASP.NET Core's dependency injection container during application startup.
IServiceProvider is the runtime service resolver built from the application's service registrations. ASP.NET Core uses it internally to create controllers and resolve registered dependencies.
Configuration is the unified system used to read application settings from multiple providers. Common providers include appsettings.json, environment-specific JSON files, environment variables, command-line arguments, user secrets, and external configuration stores.
appsettings.json is a conventional JSON configuration file used by ASP.NET Core applications. It commonly stores logging settings, connection-string names, application options, and other non-secret configuration.
IConfiguration provides key/value access to the application's combined configuration sources. It supports hierarchical keys and sections and can be injected into application services.
The Options pattern binds related configuration values to a strongly typed class and makes them available through interfaces such as IOptions<T>, IOptionsSnapshot<T>, and IOptionsMonitor<T>.
Environments allow an ASP.NET Core application to change behavior and configuration according to where it is running. Common environment names are Development, Staging, and Production.
IWebHostEnvironment provides information about the web hosting environment, including the environment name, application name, content root path, and web root path.
The content root is the base path for application content files. Configuration files, Razor files, and other application-level resources are commonly resolved relative to it.
The web root is the base directory for public static web assets. By convention, ASP.NET Core uses the wwwroot folder as the web root.
Routing matches incoming HTTP requests to executable endpoints and can also generate URLs for application endpoints.
Endpoint routing is the routing system that selects an Endpoint for an incoming request and exposes endpoint metadata to middleware and framework components.
Use adds middleware that can perform work and optionally call the next component in the pipeline. Run adds terminal middleware that does not call a next component. Map branches the pipeline based on a request path prefix.