Symptoms: Random timeouts CPU low but requests hang Root cause Blocking calls inside async code: Task.Delay(1000).Wait(); ✅ Fix await Task.Delay(1000); Rule Never block threads in ASP.NET.
Author: ErcanOPAK
ASP.NET Core Logging Slows Your API (Yes, Really)
This is expensive: _logger.LogInformation($”User {id} logged in”); ✅ Correct Way _logger.LogInformation(“User {UserId} logged in”, id); Why Avoids string interpolation Enables structured logging Reduces allocations
SQL Index Exists but Still Not Used? Here’s Why
SQL ignores indexes when: Data type mismatch Implicit conversion Example problem: WHERE UserId = ‘123’ — string ✅ Fix WHERE UserId = 123 — int Golden rule Indexes only work when types match exactly.
SQL COUNT(*) Is Slower Than You Think
This query scans rows: SELECT COUNT(*) FROM Orders; ✅ Faster Metadata Count (Approximate) SELECT SUM(row_count) FROM sys.dm_db_partition_stats WHERE object_id = OBJECT_ID(‘Orders’) AND index_id IN (0,1); Use when Dashboards Monitoring Large tables
C# ValueTask — The Hidden Performance Weapon
Most async methods return Task<T> even when they complete synchronously. ✅ Better for hot paths public ValueTask<int> GetCachedValueAsync() { return ValueTask.FromResult(42); } When to use Cache hits High-frequency calls Allocation-sensitive paths
C# Dictionary Lookup Slow? You’re Using It Wrong
This is inefficient: if (dict.ContainsKey(key)) value = dict[key]; ✅ Correct Way if (dict.TryGetValue(key, out var value)) { // use value } Why Avoids double hash lookup Faster under high frequency usage
C# Task.WhenAll Can Kill Your Server (Concurrency Trap)
This looks innocent: await Task.WhenAll(requests.Select(r => ProcessAsync(r))); But if requests = 10,000 items →you just spawned 10,000 concurrent tasks. ✅ Safe Pattern using var semaphore = new SemaphoreSlim(10); await Task.WhenAll(requests.Select(async r => { await semaphore.WaitAsync(); try { await ProcessAsync(r); } finally { semaphore.Release(); } })); Why this matters Prevents thread starvation Protects downstream services Stabilizes […]
VS “Auto-Using Not Working” — The Broken Roslyn Cache Fix
When VS stops adding using statements automatically: ✔ Fix Delete folder: %LocalAppData%\Microsoft\VisualStudio\<version>\ComponentModelCache Restart VS → everything works again.
WP “Plugin Update Breaks Site” — The Rollback Life-Saver
Use the plugin: 👉 WP Rollback Allows you to downgrade ANY plugin version instantly. 💡 Perfect for WooCommerce disasters Theme compatibility Checkout errors
Windows 11 “SSD Suddenly Slow” — Disabled Write Caching
Some updates disable write caching silently. ✔ Fix Device Manager → Disk → Properties → Enable “Write Caching”. 💡 Instant SSD speed boost.
Windows 11 “CPU Stays High for No Reason” — SearchIndexer Loop Bug
Sometimes SearchIndexer.exe loops on corrupted index. ✔ Fix Run: taskkill /IM SearchIndexer.exe /F Then rebuild index. Huge CPU drop.
AJAX “CORS Works in Postman But Fails in Browser” — Preflight Hell
99% of devs forget this: Preflight requires BOTH headers: Access-Control-Allow-Origin: * Access-Control-Allow-Headers: * ✔ Fix server side Add: Access-Control-Allow-Methods: GET,POST,PUT,DELETE 💡 Why Postman Works Postman does NOT run preflight.Browser does.
JS “Object Mutation Side Effects” — The Hidden Reference Bug
const a = { x: 5 }; const b = a; b.x = 999; Now a.x is also 999.This breaks apps everywhere. ✔ Fix: Clone before modifying const b = structuredClone(a); or: const b = { …a };
HTML5 “Form Enter Key Submits Wrong Button” — The Invisible Default Button Rule
Browser submits the first submit button by default. ✔ Fix Add formnovalidate or type=”button”: <button type=”button”>Search</button> <button type=”submit”>Save</button> 💡 Hidden Detail Prevent wrong form submissions on mobile.
CSS “Text Overflow Ellipsis Not Working” — The Missing Combo
Most devs do only: text-overflow: ellipsis; But it requires three rules: overflow: hidden; white-space: nowrap; text-overflow: ellipsis; 💡 Add max-width too for perfect control.
.NET Core “Configuration Not Updating” — Missing ReloadOnChange
If you update appsettings.json in production and nothing changes… ✔ Fix builder.Configuration.AddJsonFile( “appsettings.json”, optional: false, reloadOnChange: true ); 💡 Bonus Works even in Kubernetes (mounted config map).
ASP.NET Core “Middleware Never Executes” — The Ordering Trap
If you place middleware in the wrong order → it silently does nothing. ❌ Wrong app.UseEndpoints(…); app.UseAuthentication(); ✔ Correct app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(…); 💡 Golden Rule Auth must come BEFORE endpoints.
SQL “Dirty Reads & Weird Data” — Fix With SNAPSHOT Isolation
Readers block writers, writers block readers → chaos. ✔ The Fix Enable snapshot isolation: ALTER DATABASE MyDB SET READ_COMMITTED_SNAPSHOT ON; 💡 Why Reads no longer block updates → faster API.
SQL “Scalar Functions Destroy Performance” — The Hidden Anti-Pattern
Scalar UDFs run row-by-row → slowest possible execution. ✔ Replace with Inline Table-Valued Function CREATE FUNCTION GetPrice(@id INT) RETURNS TABLE AS RETURN SELECT Price FROM Products WHERE Id = @id; Then: SELECT p.*, f.Price FROM Orders o CROSS APPLY GetPrice(o.ProductId) f; 💡 Boost CPU ↓, IO ↓, query ↑.
C# “Regex Is Slow as Hell” — Missing Compiled Option
If regex is used repeatedly: var r = new Regex(pattern); → insanely slow. ✔ Right Way var r = new Regex(pattern, RegexOptions.Compiled); 💡 Speed Boost Up to 20× faster on repeated matches.
C# “LINQ Select N+1 Disaster” — Why Your Code Makes 500 SQL Calls
The classic mistake: var users = db.Users.ToList(); var details = users.Select(u => GetDetails(u.Id)).ToList(); If GetDetails hits DB → N+1 query explosion. ✔ SOLUTION: Use Include or Join var data = db.Users .Include(u => u.Details) .ToList(); 💡 Result 500 queries → 1 query CPU + DB load azalır API response hızlanır
C# “HttpClient Freezing Request” — The Hidden Deadlock: Sync-over-Async
Developers still do this: var response = client.GetStringAsync(url).Result; In ASP.NET = 100% guaranteed deadlock. ✔ The Real Fix Make the entire pipeline async: var response = await client.GetStringAsync(url); 💡 Hidden Detail ASP.NET sync context blocks continuation → hard deadlock.
VS “Breakpoints Hit Wrong Line” — The PDB Stale Cache Bug
Debugger attaches but steps on the wrong line?That’s stale PDB files. ✔ Fix: Delete: bin/ obj/ .vs/ Then: Clean → Rebuild → Restart VS 💡 Bonus Disable “fast up-to-date check” for large solutions.
WP “Menus Not Saving” — The Max Input Vars Killer
Your menu refuses to save?You click save → NOTHING. ✔ Fix in php.ini: max_input_vars = 3000 Or WP-level: @ini_set( ‘max_input_vars’ , 3000 ); 💡 Why It Happens Large menus exceed PHP’s default 1000 variable limit.
Windows 11 “Search Bar Broken or Empty” — Rebuild Index the RIGHT Way
Most people rebuild the index the wrong way. ✔ Correct Solution Run: PowerShell -Command “Get-AppxPackage Microsoft.Windows.Search* | Reset-AppxPackage” Then rebuild index. Fixes search for 99% of users.
Windows 11 “UI Stuttering” — The Hidden Hardware Accelerated GPU Scheduling Bug
For some GPUs, HAGS causes micro-stutters. ✔ Fix Turn off: Settings → System → Display → Graphics → Change default graphics settings → Hardware Accelerated GPU Scheduling = Off Instant smoothness boost.
AJAX “POST Works Locally but Not in Production” — HTTPS Mixed Content
Local: HTTPProd: HTTPSBrowser blocks insecure AJAX calls with no error. ✔ Fix Always use relative URLs: $.post(‘/api/users’, data); Avoid: $.post(‘http://localhost/api/users’, data); // ❌
JS “setInterval Drift” — Why Your Timers Run Slower Over Time
setInterval accumulates drift because execution time is included. ✔ Fix: Self-adjusting timer const start = Date.now(); let count = 0; function tick() { count++; const next = start + count * 1000; setTimeout(tick, next – Date.now()); } tick(); Accurate to the millisecond.
HTML5 “Broken Autofill Styles” — Chrome’s Yellow Background Bug
Chrome applies weird autofill yellow color using a shadow DOM style. ✔ Fix input:-webkit-autofill { -webkit-box-shadow: 0 0 0 1000px white inset; } 💡 Works for: light themes dark themes password inputs
CSS “Z-Index Doesn’t Work!” — The Parent Stacking Context Curse
The REAL reason z-index fails: A parent has position + z-index→ it creates a new stacking context. ✔ Fix Remove z-index from parent OR apply a higher z-index to the parent itself. 💡 Debug Trick Apply: outline: 2px solid red; To visualize stacking contexts.








