Skip to main content

Posts

Recent posts

ASP.NET Core Rate Limiting: Protect Your API (2026)

Learn ASP.NET Core rate limiting with built-in .NET middleware. Fixed window, sliding window, token bucket & code examples. Secure your API today! If your API is public, it will be abused — by scrapers, misconfigured clients stuck in retry loops, brute-force login bots, or a single power user hammering an expensive endpoint. ASP.NET Core rate limiting is the first line of defense, and since .NET 7 it has been built directly into the framework via the Microsoft.AspNetCore.RateLimiting middleware — no third-party packages required. In this tutorial you'll learn how to configure all four built-in rate limiting algorithms in .NET 8, 9, and 10, how to apply limits per user or per IP address, how to return proper 429 Too Many Requests responses, and the pitfalls that trip up production deployments (especially behind load balancers). Why Rate Limiting Matters in 2026 Rate limiting is not just a security checkbox. It solves several distinct problems, and knowing which pro...

C# Collections Performance: List vs Dictionary vs HashSet

Master C# collections performance: List vs Dictionary vs HashSet vs Queue with Big-O tables, real benchmarks, and code examples. Pick the right one today. Choosing the right data structure is one of the highest-leverage performance decisions you can make in .NET — and C# collections are where most of those decisions happen. Should you use a List<T> or a Dictionary<TKey, TValue> ? When does a HashSet<T> beat both? And where does Queue<T> fit in? In this guide, we'll compare the four most-used collections in C# with Big-O complexity tables, runnable benchmark code, and clear rules for when to use each. By the end, you'll be able to justify your collection choice in a code review — not just guess. Why C# Collections Performance Matters Every collection type in .NET makes a trade-off. List<T> gives you cheap indexed access and great iteration speed but slow lookups by value. Dictionary<TKey, TValue> gives you near-instant lookups...

API Versioning in ASP.NET Core: Complete Guide (2026)

Learn API versioning in ASP.NET Core with real code examples — URL, header, and query string strategies. Build APIs that never break clients. Start now! API versioning in ASP.NET Core is one of those topics every backend developer eventually runs into — usually the hard way. You ship an API, mobile apps and third-party clients start depending on it, and then the business asks for a change that would break every one of them. Versioning is how you evolve your API without burning down the integrations built on top of it. In this guide, you'll learn the four main API versioning strategies, how to implement each one in ASP.NET Core using the official Asp.Versioning packages, how to version Minimal APIs, and the best practices (and pitfalls) that separate a maintainable API from a support nightmare. Why API Versioning Matters An API is a contract. Once a client — a React frontend, an iOS app, a partner's integration — starts consuming it, you no longer fully own its sha...

How to Dockerize an ASP.NET Core App in .NET 9

Learn how to dockerize an ASP.NET Core app in .NET 9 with a step-by-step Dockerfile tutorial, best practices, and deployment tips. Start containerizing today! If you want to dockerize an ASP.NET Core app , .NET 9 makes it easier than any previous release. Containers have become the default way to ship web applications — every major cloud (Azure, AWS, Google Cloud) runs them natively, and "it works on my machine" bugs largely disappear when your app ships with its entire runtime environment. In this tutorial, you'll learn how to containerize a .NET 9 ASP.NET Core application with a production-ready Dockerfile, understand why each instruction matters, run it locally with Docker Compose, and deploy it to the cloud. We'll also cover the built-in SDK container publishing feature that lets you skip the Dockerfile entirely. Why Dockerize an ASP.NET Core App? Before writing any code, it's worth understanding what containers actually buy you, because the "why...

Prevent XSS in ASP.NET Core: Complete Security Guide

Learn how to prevent cross-site scripting (XSS) in ASP.NET Core with encoding, CSP, and sanitization. Complete guide with C# code examples — read now. Cross-site scripting (XSS) has appeared in every OWASP Top 10 list since the project began, and it remains one of the most commonly reported vulnerabilities in web applications today. If you build web apps with ASP.NET Core, the good news is that the framework gives you strong cross-site scripting prevention out of the box — but only if you understand where those protections apply and, more importantly, where they silently stop applying. This complete guide explains what XSS is, how attackers exploit it, and exactly how to prevent it in ASP.NET Core using output encoding, Content Security Policy, HTML sanitization, and secure cookie configuration. What Is Cross-Site Scripting (XSS)? Cross-site scripting is an injection attack where an attacker gets their own JavaScript to run in another user's browser, in the security con...

Deploy ASP.NET Core to Azure App Service in 10 Minutes

Learn how to deploy ASP.NET Core to Azure App Service in 10 minutes using the Azure CLI, Visual Studio, and GitHub Actions. Start deploying today! If you want to deploy ASP.NET Core to Azure App Service , you are looking at the fastest, most battle-tested path to getting a .NET web app into production. Azure App Service is Microsoft's fully managed hosting platform — it handles the web servers, load balancing, TLS certificates, patching, and scaling so you can focus on shipping code. In this tutorial you will take a brand-new ASP.NET Core application from dotnet new to a live public URL in about 10 minutes, using three different methods: the Azure CLI (fastest), Visual Studio (most familiar), and GitHub Actions (the way real teams do it). More importantly, we will cover why each step matters, the configuration mistakes that cause the dreaded HTTP 500.30 startup error, and the best practices that separate a demo deployment from a production-ready one. What Is Azure App Se...