Middleware reading body breaks controllers. ✅ Fix Enable buffering: context.Request.EnableBuffering(); Then rewind stream.
Author: ErcanOPAK
Scoped Services Inside Singleton = Time Bomb
public class MySingleton { public MySingleton(MyScopedService s) { } } ❌ Problem Captures first request scope forever Causes stale data & memory leaks ✅ Fix Use IServiceScopeFactory.
Implicit Data Type Conversion Breaks Index Usage
WHERE UserId = ‘123’ Column is INT. ❌ Result Index ignored Full scan ✅ Fix Match types exactly.
Why MERGE Can Corrupt Data Under Concurrency
MERGE looks elegant… but has known race issues. ❌ Risks Duplicate inserts Missed updates Hard-to-reproduce bugs ✅ Safer Pattern Explicit UPDATE + INSERT with transaction.
Expression Trees Can Kill Startup Time
Heavy use of expression compilation: Expression<Func<T, bool>> ❌ Cost JIT + dynamic method generation Slow cold starts ✅ Fix Cache compiled expressions aggressively.
Why lock(this) Can Deadlock Your Entire App
lock(this) { // work } Hidden problem External code can lock the same instance Causes unpredictable deadlocks ✅ Correct private readonly object _lock = new(); lock (_lock) { }
GC.AllocateUninitializedArray — Faster Arrays With a Catch
GC.AllocateUninitializedArray — Faster Arrays With a Catch Why it’s fast Skips zero-initialization Reduces CPU cycles ⚠ Danger Memory contains garbage values Must fully overwrite before use Use case High-performance serializers, buffers, pipelines.
Solution Loads Slowly — Roslyn Cache Corruption
VS silently rebuilds analyzers. ✅ Fix Delete: %LOCALAPPDATA%\Microsoft\VisualStudio\17.* Reopen solution → instant load.
WordPress Slow Even With Cache — Autoloaded Options
Huge autoload rows load on every request. ✅ Fix Audit: SELECT * FROM wp_options WHERE autoload=’yes’; Disable unused entries.
High RAM Usage With Nothing Open
Cause: Memory Compression. Windows compresses memory instead of freeing it. ✅ Tip High usage ≠ problem unless paging starts.
Windows 11 Defender Slowing Down Builds
Real-time scanning kills compile speed. ✅ Fix Exclude: bin/ obj/ build output folders
CORS Errors That Are NOT CORS Errors
Most “CORS issues” are actually: 401 responses Missing headers Redirects ✅ Debug Tip Check Network → Response headers, not console.
Event Listeners Causing Memory Leaks
Detached DOM nodes still hold listeners. ❌ Problem element.addEventListener(…) ✅ Fix Remove listeners explicitly or use { once: true }.
input type=”number” Breaks Mobile UX
Mobile keyboards behave inconsistently. ✅ Better <input inputmode=”numeric” pattern=”[0-9]*”> Result Better mobile keyboards Fewer validation issues
will-change Can Make Performance Worse
will-change: transform; ❌ Overuse causes: GPU memory pressure Slower rendering ✅ Rule Apply only shortly before animation, remove after.
Model Binding Is Slower Than You Think
Large request models cost CPU. ✅ Optimization Use [FromBody] DTOs instead of giant domain models. Why Less reflection Faster deserialization Cleaner APIs
IOptionsSnapshot vs IOptionsMonitor — Subtle but Critical
Wrong choice causes stale configs or memory leaks. IOptionsSnapshot → per request IOptionsMonitor → real-time updates ✅ Rule Use Monitor only if config changes at runtime.
Why NVARCHAR(MAX) Can Destroy Query Plans
Using NVARCHAR(MAX) everywhere is tempting. ❌ Hidden cost Prevents index usage Breaks memory grants ✅ Rule Use fixed lengths when possible: NVARCHAR(255)
DATEDIFF in WHERE Clause Disables Indexes
This looks innocent: WHERE DATEDIFF(day, CreatedAt, GETDATE()) = 0 ❌ Why it’s bad Forces full scan Index becomes useless ✅ Fix WHERE CreatedAt >= CAST(GETDATE() AS date)
Equals() Without GetHashCode() Breaks HashSets
Overriding only Equals() is a bug factory. public override bool Equals(object obj) { … } ❌ Missing: public override int GetHashCode() { … } Result HashSet duplicates Dictionary lookups fail silently
Why Dictionary Suddenly Becomes Slow
The hidden killer: rehashing. When capacity grows, the dictionary reallocates everything. ✅ Fix Always pre-size: var dict = new Dictionary<int, User>(expectedCount); Real impact Eliminates random latency spikes Crucial in hot paths
Span — The Secret Weapon for Zero-Allocation Code
Most high-performance .NET code avoids allocations entirely. Span<char> buffer = stackalloc char[64]; Why this matters Zero GC pressure Massive performance boost in parsing & serialization Used heavily inside .NET itself ⚠ Cannot escape the method scope.
Breakpoints Not Hit — Wrong Startup Project
Multi-project solutions bite hard. ✅ Fix Right-click correct project → Set as Startup Project
WordPress Images Killing Performance — Missing Sizes
Uploading huge images without resizing is deadly. ✅ Fix Always use: the_post_thumbnail(‘medium_large’);
Background Apps Draining Laptop Battery
Many apps run unseen. ✅ Fix Settings → Apps → Startup → Disable unused apps
Windows 11 Sluggish UI — Animation Overhead
Animations cost GPU time. ✅ Fix Settings → Accessibility → Visual Effects → Disable animations
AJAX Requests Canceled on Page Navigation
Requests silently stop. 🧠 Reason Browser cancels in-flight requests. ✅ Fix Use navigator.sendBeacon() for critical logs.
Floating Point Math Is Lying to You
0.1 + 0.2 === 0.3 // false ✅ Fix Use rounding: Number((0.1 + 0.2).toFixed(2))
Inside forms, this causes accidental submits. ❌ <button>Click</button> ✅ Fix <button type=”button”>Click</button>
overflow-x: hidden Is Not a Layout Fix
Using this hides bugs instead of fixing them. ✅ Proper Fix Identify overflowing element Fix width or flex behavior








