🌐 ASP.NET Core

Build modern web applications and APIs using the powerful ASP.NET Core framework.

What is ASP.NET Core?

ASP.NET Core is a cross-platform, high-performance framework for building modern, cloud-based, internet-connected applications. It's redesigned from the ground up to be fast, flexible, and modular.

Key Features

Minimal APIs

Create lightweight APIs with minimal code:

var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); app.MapGet("/", () => "Hello World!"); app.MapGet("/users/{id}", (int id) => new User(id, $"User {id}")); app.MapPost("/users", (User user) => Results.Created($"/users/{user.Id}", user)); app.Run(); record User(int Id, string Name);

Controllers and MVC

For larger applications, use controllers:

[ApiController] [Route("api/[controller]")] public class ProductsController : ControllerBase { private readonly IProductService _service; public ProductsController(IProductService service) { _service = service; } [HttpGet] public async Task<ActionResult<IEnumerable<Product>>> GetAll() { var products = await _service.GetAllAsync(); return Ok(products); } [HttpGet("{id}")] public async Task<ActionResult<Product>> GetById(int id) { var product = await _service.GetByIdAsync(id); return product is null ? NotFound() : Ok(product); } }

Middleware Pipeline

Configure request processing with middleware:

var builder = WebApplication.CreateBuilder(args); // Add services builder.Services.AddControllers(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); var app = builder.Build(); // Configure middleware if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.UseHttpsRedirection(); app.UseAuthentication(); app.UseAuthorization(); app.MapControllers(); app.Run();

Getting Started

← Back to Developer Resources