Introduction
ASP.NET Core is Microsoft's framework for building web apps and APIs in C# — cross-platform, open source, and the direct successor to the older, Windows-only ASP.NET. This lesson assumes you already know C#; if you don't, the site's C# course covers it first.
Creating a new project
The dotnet CLI scaffolds a new project from a template. web gives you a minimal, empty ASP.NET Core project — no MVC folders, no extra files:
dotnet new web -o HelloApi cd HelloApi dotnet run
Building...
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5225
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: DevelopmentThe project is now a real, running web server. Visiting http://localhost:5225 in a browser hits whatever code you've mapped to that URL.
The minimal Program.cs
Modern ASP.NET Core apps start from a single, short Program.cs — no separate Startup class required for a small project:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", () => "Hello, ASP.NET Core!");
app.Run();
Hello, ASP.NET Core!
WebApplication.CreateBuilder(args) sets up configuration, logging, and dependency injection with sensible defaults. app.MapGet(...) maps a URL pattern and HTTP method to a handler — you'll see much more of this in the next lesson. app.Run() starts the server and blocks until it's shut down.