Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
Reading Old .NET Core 3.1 and .NET 5 Projects: Migrating from Startup.cs to .NET 6
We read the Startup.cs, Generic Host and UseRouting/UseEndpoints structure of the .NET Core 3.1 and .NET 5 era, then move the same ASP.NET Core API to .NET 6 step by step, including System.Text.Json differences.
Containerizing an ASP.NET Core Web API with Docker and Setting Up CI/CD with GitHub Actions
We containerize an ASP.NET Core Web API with a multi-stage Dockerfile: dotnet publish, the layer cache, .dockerignore, ports and environment settings; then we build a GitHub Actions CI/CD pipeline that tests the code and pushes the image to ghcr.io.
Integration Testing an ASP.NET Core Web API: End-to-End Tests with WebApplicationFactory
We spin up an ASP.NET Core Web API in memory with WebApplicationFactory and test it at the HTTP level: public partial class Program, swapping the database for in-memory SQLite, Location and ProblemDetails tests, and test isolation.
Unit Testing an ASP.NET Core Web API: Service and Controller Tests with xUnit and Moq
Unit testing an ASP.NET Core Web API with xUnit and Moq: the right package versions for net6.0, AAA and naming, Setup and Verify, the Result/Value difference in ActionResult<T> tests, Theory, and a comparison with NSubstitute.
Health Checks in ASP.NET Core Web API: Liveness, Readiness and Database Checks
Health checks in ASP.NET Core Web API: a database check with AddDbContextCheck, a Redis check with IHealthCheck, separating liveness and readiness, why Degraded returns 200, JSON output and timeout pitfalls.
Caching in ASP.NET Core Web API: IMemoryCache, Redis and Response Caching
Caching in ASP.NET Core Web API: absolute and sliding expiration with IMemoryCache, delete-on-write invalidation, IDistributedCache with Redis, and which requests the response caching middleware won't cache and why.
Swagger and OpenAPI in ASP.NET Core Web API: Documentation with Swashbuckle
We add an OpenAPI document and Swagger UI to an ASP.NET Core Web API with Swashbuckle: the right package version, XML comments, documenting response types, an Authorize button for JWT, and common pitfalls with real error messages.
ASP.NET Core Web API Versioning: URL, Query String and Header with Asp.Versioning
To ship breaking changes without breaking old clients, we build a two-version API with Asp.Versioning.Mvc. We try URL, query string and header readers, plus deprecation and the Sunset header.
CORS and Security in ASP.NET Core Web API: HTTPS, HSTS, Headers and Secrets
We see with curl why CORS is not a firewall, define a policy and read the preflight request. HTTPS redirection, the localhost exception in HSTS, security headers and user secrets are covered too.
Authorization in ASP.NET Core Web API: Roles, Policies and Resource-Based Authorization
We start with [Authorize] and FallbackPolicy, then move to roles, policies, our own requirement and handler, and resource-based authorization. We see the RoleClaimType trap and 401 vs 403 with curl.
Authentication with JWT in ASP.NET Core Web API: Issuing and Validating Tokens
From the authentication vs authorization split to the anatomy of a JWT, we build a login flow with AddJwtBearer and JsonWebTokenHandler. ClockSkew, claim mapping and the refresh token idea are covered too.
File Upload and Download in ASP.NET Core Web API: IFormFile, Limits and Streaming
We upload book cover images with IFormFile and guard against path traversal and fake extensions. We cover Kestrel and form limits, downloads with PhysicalFile and streaming with MultipartReader.