Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
EF Core and SQLite in ASP.NET Core Web API: DbContext, the First Migration and CRUD
We add a data layer to an ASP.NET Core Web API with EF Core and SQLite: EF Core 6 and 10 package versions, AppDbContext, the connection string, why DbContext is scoped, the first migration, async CRUD and the SQL in the console.
Logging in ASP.NET Core: ILogger, Log Levels, Structured Logging and Serilog
We write logs with ILogger<T> in ASP.NET Core: categories, log levels, filters via appsettings and environment variables, structured logging with message templates, scopes, the LoggerMessage source generator and the Serilog version that supports net6.0.
Configuration and the Options Pattern in ASP.NET Core: Provider Order, User Secrets and Validation
We see the order of ASP.NET Core configuration providers with real output: appsettings, environment variables, command line, user secrets. The Options pattern, IOptions vs IOptionsSnapshot vs IOptionsMonitor, and validation with ValidateOnStart.
Dependency Injection in ASP.NET Core: Lifetimes and the Captive Dependency Trap
We explore dependency injection in ASP.NET Core with real output: constructor injection, singleton/scoped/transient lifetimes, captive dependencies, scope validation, IServiceProvider and the [FromServices] detail in .NET 6.
ASP.NET Core Minimal APIs with .NET 6: MapGet, MapPost and How They Compare to Controllers
MapGet, MapPost, MapPut and MapDelete with .NET 6 minimal APIs, parameter binding rules, Results helpers, filling in the missing validation by hand, grouping endpoints, and when to pick minimal APIs over controllers.
Model Validation in ASP.NET Core: Data Annotations and FluentValidation
Model validation with Data Annotations, ModelState and the automatic 400, customizing ValidationProblemDetails, custom attributes, IValidatableObject and FluentValidation 11.x, including culture pitfalls with Range and messages.
Model Binding in ASP.NET Core: FromRoute, FromQuery, FromBody and FromHeader
How request data binds to action parameters from the route, query string, body, headers, forms and services, the inference rules of [ApiController], and why you get 415 and 400 errors, with real responses.
Status Codes and Responses in ASP.NET Core: Ok, CreatedAtAction and ProblemDetails
Returning the right status code with ControllerBase helpers, the surprise 204 on null, CreatedAtAction and the Location header, choosing between 400/404/409, ProblemDetails and content negotiation, with real responses.
Controllers and Actions in ASP.NET Core: A CRUD Skeleton with [ApiController]
The difference between ControllerBase and Controller, the four behaviors [ApiController] adds, choosing between IActionResult and ActionResult<T>, and an in-memory CRUD skeleton, all with real curl output.
Routing in ASP.NET Core Web API: Attribute Routing, Route Templates and Constraints
The decide-and-execute steps of endpoint routing, attribute routing and the [controller]/[action] tokens, route template parts, constraints and precedence, conflicting routes and AmbiguousMatchException.
The ASP.NET Core Middleware Pipeline: Ordering, Use, Run, Map and Your Own Middleware
We follow a request through the middleware rings and the response back out: Use, Run and Map, writing middleware as a class, the effect of ordering, the recommended order of built-in middleware and typical pitfalls.
Program.cs and the Hosting Model in ASP.NET Core: WebApplication and Environments
The two phases of the minimal hosting model: preparing services, configuration and logging on the builder, then the pipeline and endpoints on the app. Environments, app.Run() and the Generic Host behind it all.