Why Async Can Be Slower in Real Projects?

Async/await is powerful but overused. This guide breaks down async misconceptions, shows real enterprise use cases, and gives you a practical decision framework for async in C#.

August 1, 2025 · 14 min

IEquatable in C#: Why Every .NET Developer Should Master Custom Equality

Master IEquatable in C# to optimize equality checks, improve collection performance, and eliminate boxing overhead. Essential for value types and collections.

July 16, 2025 · 9 min

Violating SOLID for Performance: When It’s Okay and How to Isolate It

Discover when it’s justified to break SOLID principles for performance in C#. Learn how to measure, isolate, and document exceptions, see real-world trade-offs, and keep your codebase maintainable, even in the engine bay of high-throughput systems.

July 10, 2025 · 10 min

Avoiding N+1 Queries in EF Core: Include() vs SplitQuery()

A practical guide to fixing N+1 queries in EF Core using Include and AsSplitQuery, with code samples and performance tips.

July 8, 2025 · Last modified: July 10, 2025 · 11 min

Avoiding Boxing with Struct Dictionary Keys in C#: Performance and Best Practices

Discover why structs as dictionary keys can cause hidden allocations in C#. Learn how to implement IEquatable, use readonly and record structs, and write allocation-free, high-performance code for hot paths.

July 6, 2025 · 4 min

ASP.NET Core Middleware Order: Fix Pipeline Issues and Debug Execution Flow

TL;DR Middleware order in ASP.NET Core directly affects authentication, CORS, routing, and logging. Register exception handling, HTTPS redirection, and logging middleware early in the pipeline. Place CORS before authentication and routing to avoid preflight and header issues. Authentication must come before authorization and routing for secure endpoints. Use tools like MiddlewareAnalysis and custom logging middleware to debug pipeline flow. Common mistakes include routing before authentication, CORS after auth, and late exception handling. Correct middleware order prevents security holes, debugging nightmares, and production outages. The Hidden Culprit Behind Mysterious Pipeline Failures Picture this: your ASP.NET Core API works perfectly in development, but authentication randomly fails in production. CORS headers appear inconsistently. Some endpoints return 404s that should work. The logs show everything should be working correctly. ...

July 4, 2025 · 9 min
Diagram showing controlled parallel file processing with throttling compared to naive approaches

High-Volume File Processing in C#: Efficient Patterns for Handling Thousands of Files

TL;DR: Efficient C# File Processing Strategies Prevent system crashes: Avoid naive parallel processing that launches thousands of concurrent file operations. Optimize throughput: Use SemaphoreSlim to control concurrency (start with 2x CPU cores) for balanced performance. Reduce memory consumption: Implement true async I/O with useAsync: true and process files line-by-line instead of loading them entirely. Minimize database overhead: Batch related records from multiple files before making database calls. Maximize system resources: For production systems, implement adaptive throttling that responds to CPU/memory conditions. Leverage modern C# features: Use IAsyncEnumerable for efficient streaming and TPL Dataflow for complex processing pipelines. Ever tried to build an import tool that needs to process thousands of CSV files at once? I have, and I learned the hard way that simply starting a thousand file operations simultaneously is a recipe for disaster. ...

July 4, 2025 · Last modified: July 10, 2025 · 18 min

ASP.NET Core HTTP Logging Middleware: 13 Practical Micro Tips

TL;DR - Practical Tips for ASP.NET Core HTTP Logging Middleware Use EnableBuffering() to safely log request bodies and reset stream position after reading. Capture response bodies by swapping HttpResponse.Body with a MemoryStream and restoring after logging. Always filter or redact sensitive data before logging HTTP bodies. Set size limits and skip large or binary payloads to avoid performance issues. Filter logs by endpoint, HTTP method, or custom attributes for clarity. Built-in HttpLogging is simple; custom middleware offers full control and advanced filtering. Use structured logging and external services for production monitoring. Wrap middleware in extension methods for clean, configurable registration. Leverage PipeReader and System.IO.Pipelines for more efficient memory usage. Use Span<T> and ArrayPool<T> for zero-allocation processing of large payloads. Consider implementing request sampling in production to reduce log volume. Use a complete middleware implementation that combines all best practices. 1. How does EnableBuffering help you log request bodies in ASP.NET Core? EnableBuffering allows you to read request bodies multiple times without breaking the pipeline. ...

July 2, 2025 · Last modified: July 9, 2025 · 15 min

Implementing Request Throttling Middleware in ASP.NET Core Using MemoryCache and Per-IP Limits

Protect your ASP.NET Core APIs from abuse with custom request throttling middleware using IMemoryCache and per-IP limits. Learn to implement, configure, and monitor rate limiting for robust, high-performance APIs.

July 2, 2025 · Last modified: July 10, 2025 · 10 min

Angular @defer: Cut Initial Load Time by 97% [Real Benchmarks & Code]

TL;DR: Angular’s @defer directive delays non-critical UI rendering, cutting initial load time by up to 97% in real apps. Use it to lazy load heavy components, reduce Time to Interactive (TTI), and improve Core Web Vitals. Includes real benchmarks and production-ready examples. Introduction Ever loaded up an Angular app and watched that progress bar crawl while your users bail? Yeah, me too. That’s why I got so excited when the Angular team released the @defer feature. It’s a game-changer for those of us battling slow initial load times. ...

June 23, 2025 · Last modified: July 3, 2025 · 21 min
×