ASP.NET Core
Overview
ASP.NET Core is a cross-platform, open-source .NET framework for building modern cloud-based web applications on Windows, macOS, or Linux. It supports web apps, REST/Minimal APIs, gRPC, real-time apps with SignalR, and the Blazor frontend model. Read this when building .NET HTTP services or web apps. Requires the .NET SDK.
Official sources
Install / setup
# Install the latest .NET SDK first (https://dotnet.microsoft.com/download/dotnet)
# Create a Blazor Web App
dotnet new blazor -o BlazorSample
cd BlazorSample
# Run with hot reload
dotnet watch
# Or create a Razor Pages web app
dotnet new webapp -o RazorPagesSample
Core concepts
- Host & startup:
WebApplication.CreateBuilder configures services and the request pipeline; app.Run() starts the server.
- Middleware pipeline: ordered components process each request/response (routing, auth, static files); order matters.
- Dependency injection: a built-in DI container registers services with lifetimes (singleton, scoped, transient) consumed via constructor injection.
- Routing & endpoints: Minimal APIs, controllers, and Razor Pages map URLs to handlers via endpoint routing.
- Configuration & options: layered configuration (appsettings.json, env vars, user secrets) bound to strongly typed options.
- Blazor & Razor: component-based UI (Blazor) and the Razor syntax mixing HTML with C# for server-rendered pages.
Best practices
- Use
dotnet watch during development for hot reload of markup and code (https://learn.microsoft.com/aspnet/core/getting-started).
- Register dependencies in the DI container and inject them rather than constructing them manually.
- Order middleware deliberately; place routing, authentication, and authorization in the documented sequence.
- Use the configuration/options system and user secrets for settings instead of hardcoding values.
Common pitfalls
- Misordering middleware (e.g. authorization before routing) → requests bypass or mishandle auth; follow the documented pipeline order.
- Choosing the wrong project template →
dotnet new blazor scaffolds Blazor, dotnet new webapp scaffolds Razor Pages; pick what matches your app.
- Storing secrets in appsettings.json committed to source control → use user secrets in development and a secret store in production.
Examples
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/ping", () => "pong");
app.Run();
Further reading
Related skills
- ../actix — high-performance compiled-language web framework (Rust)
- ../laravel — full-stack web framework alternative (PHP)
1---2name: aspnet-core3description: Cross-platform, open-source .NET web framework for cloud apps, web APIs, and Blazor; consult when building or maintaining ASP.NET Core backends.4domain: stack5category: backend6tags: [dotnet, csharp, aspnet-core, web-api, web-framework]7official_sources:8 - https://learn.microsoft.com/aspnet/core/9 - https://github.com/dotnet/aspnetcore10verified: 2026-06-1611metadata:12 source: https://skillmd.com/skills/gabriel7silva/aspnet-core13---1415# ASP.NET Core1617## Overview18ASP.NET Core is a cross-platform, open-source .NET framework for building modern cloud-based web applications on Windows, macOS, or Linux. It supports web apps, REST/Minimal APIs, gRPC, real-time apps with SignalR, and the Blazor frontend model. Read this when building .NET HTTP services or web apps. Requires the .NET SDK.1920## Official sources21- Docs: https://learn.microsoft.com/aspnet/core/22- Repo: https://github.com/dotnet/aspnetcore23- Install / download: https://learn.microsoft.com/aspnet/core/getting-started (SDK: https://dotnet.microsoft.com/download/dotnet)2425## Install / setup26```bash27# Install the latest .NET SDK first (https://dotnet.microsoft.com/download/dotnet)2829# Create a Blazor Web App30dotnet new blazor -o BlazorSample31cd BlazorSample3233# Run with hot reload34dotnet watch35```36```bash37# Or create a Razor Pages web app38dotnet new webapp -o RazorPagesSample39```4041## Core concepts42- Host & startup: `WebApplication.CreateBuilder` configures services and the request pipeline; `app.Run()` starts the server.43- Middleware pipeline: ordered components process each request/response (routing, auth, static files); order matters.44- Dependency injection: a built-in DI container registers services with lifetimes (singleton, scoped, transient) consumed via constructor injection.45- Routing & endpoints: Minimal APIs, controllers, and Razor Pages map URLs to handlers via endpoint routing.46- Configuration & options: layered configuration (appsettings.json, env vars, user secrets) bound to strongly typed options.47- Blazor & Razor: component-based UI (Blazor) and the Razor syntax mixing HTML with C# for server-rendered pages.4849## Best practices50- Use `dotnet watch` during development for hot reload of markup and code (https://learn.microsoft.com/aspnet/core/getting-started).51- Register dependencies in the DI container and inject them rather than constructing them manually.52- Order middleware deliberately; place routing, authentication, and authorization in the documented sequence.53- Use the configuration/options system and user secrets for settings instead of hardcoding values.5455## Common pitfalls56- Misordering middleware (e.g. authorization before routing) → requests bypass or mishandle auth; follow the documented pipeline order.57- Choosing the wrong project template → `dotnet new blazor` scaffolds Blazor, `dotnet new webapp` scaffolds Razor Pages; pick what matches your app.58- Storing secrets in appsettings.json committed to source control → use user secrets in development and a secret store in production.5960## Examples61```csharp62var builder = WebApplication.CreateBuilder(args);63var app = builder.Build();6465app.MapGet("/ping", () => "pong");6667app.Run();68```6970## Further reading71- https://learn.microsoft.com/aspnet/core/getting-started — Get started72- https://learn.microsoft.com/aspnet/core/tutorials/min-web-api — Minimal API tutorial73- https://learn.microsoft.com/aspnet/core/fundamentals/ — Fundamentals (DI, middleware, configuration)7475## Related skills76- ../actix — high-performance compiled-language web framework (Rust)77- ../laravel — full-stack web framework alternative (PHP)