ASP.NET Core Overview

What is ASP.NET Core?

ASP.NET Core is a cross-platform, high-performance, open-source framework for building modern, cloud-enabled, internet-connected applications. It's the next generation of ASP.NET and is designed from the ground up to provide a more modular, testable, and performant development experience.

Key characteristics of ASP.NET Core include:

Key Concepts

Middleware Pipeline

ASP.NET Core applications are built using a series of middleware components that process HTTP requests. Each middleware can:

Common middleware includes static file handling, authentication, routing, and MVC endpoint routing.


// Example of configuring the middleware pipeline
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.MapRazorPages();
app.MapControllers();
app.Run();
            

Dependency Injection

ASP.NET Core has built-in support for dependency injection (DI). This promotes loosely coupled code, making applications easier to test and maintain. Services can be registered with the DI container and injected into controllers, Razor Pages, or other services.

Configuration

ASP.NET Core provides a flexible configuration system that allows you to manage application settings from various sources, including JSON files, environment variables, command-line arguments, and Azure Key Vault.

Hosting

Applications can be hosted on-premises, in the cloud (e.g., Azure App Service, Docker containers), or using Kestrel, the cross-platform web server included with ASP.NET Core.

Application Models

ASP.NET Core supports several models for building web applications:

Getting Started

To start building with ASP.NET Core, you'll need:

You can create a new ASP.NET Core project using the .NET CLI:


dotnet new webapp -o MyAspNetCoreApp
cd MyAspNetCoreApp
dotnet run
            

This command creates a new Razor Pages web application and starts it.

Resources

For more in-depth information, explore the official Microsoft documentation: