ASP.NET Core is the framework you use to build web applications and APIs with .NET. If you have ever used Node.js with Express, Python with Flask, or Java with Spring, ASP.NET Core is Microsoft's answer to those โ and honestly, it is one of the fastest web frameworks out there.
What Is ASP.NET Core?
ASP.NET Core is a cross-platform, high-performance framework for building web apps and APIs. It runs on Windows, macOS, and Linux. The "Core" part means it is the modern, redesigned version of the original ASP.NET framework.
Here is what makes it special:
- Fast. It consistently ranks among the fastest web frameworks in benchmarks.
- Cross-platform. Deploy to Windows, Linux, or macOS without changing code.
- Open source. The entire framework is on GitHub, and the community contributes actively.
- Built-in dependency injection. No need for third-party containers.
- Middleware pipeline. Clean, composable request handling.
Your First Web API
Let us create a simple web API. Open your terminal and run:
dotnet new webapi -n MyFirstApi
cd MyFirstApi
dotnet run
This creates a new Web API project. By default, it sets up a minimal API with a weather
forecast endpoint. Open your browser and navigate to the URL shown in the terminal
(usually https://localhost:5001).
You should see JSON data returned. You just built your first API. That was quick, right?
Understanding the Project Structure
Let me walk you through the important files:
Program.csโ the entry point. This is where you configure services and middleware.appsettings.jsonโ configuration file (connection strings, ports, etc.)Controllers/โ where your API controllers live (if you use the controller pattern)
In .NET 6 and later, the Program.cs file is simplified. You no longer need the
Startup.cs class โ everything is configured in one place.
Minimal API vs Controllers
ASP.NET Core supports two ways to define endpoints:
// Minimal API (simpler, great for small APIs)
app.MapGet("/api/hello", () => "Hello, World!");
// Controller-based (better for larger APIs)
[ApiController]
[Route("api/[controller]")]
public class HelloController : ControllerBase
{
[HttpGet]
public IActionResult Get()
{
return Ok("Hello, World!");
}
}
For beginners, minimal APIs are easier to understand. As your project grows, controllers provide better organization. We will cover both in the following lessons.