Many background workers never stop on SIGTERM. ✔ Real Fix Bind cancellation token: public Task StartAsync(CancellationToken ct) { _ = DoWorkAsync(ct); return Task.CompletedTask; } 💡 Super Tip In Program.cs: builder.Services.AddHostedService<MyWorker>(); builder.Services.Configure<HostOptions>(o => { o.ShutdownTimeout = TimeSpan.FromSeconds(20); }); Most devs don’t know this exists → massively improves controlled shutdown.
Author: ErcanOPAK
.NET Core Dependency Injection “Multiple Registrations” Bug
This bug causes random services to switch implementations unexpectedly. ⚠ Problem Registering twice: services.AddSingleton<IMailer, SmtpMailer>(); services.AddSingleton<IMailer, FakeMailer>(); ASP.NET Core uses the last registration → extremely hard-to-debug issues. ✔ Fix Remove duplicates OR name your registrations: services.AddSingleton<IMailer, SmtpMailer>(“smtp”); 💡 Hidden Debug Trick Log all registrations: services.ToList().ForEach(x => Console.WriteLine(x.ServiceType));
SQL “Blocking Sessions” — The Hidden Killer: Orphaned Transactions
Long-running transaction = entire DB slowdown. ✔ Quick Diagnostic SELECT * FROM sys.dm_tran_active_transactions; If you see an uncommitted transaction running for hours → that’s your culprit. ✔ The Fix Enable XACT_ABORT to auto-kill faulty transactions: SET XACT_ABORT ON; This is rarely known but prevents ghost locks forever.
SQL “Slow Pagination” — The Secret Trick: Seek Method
Most devs use: ORDER BY Id OFFSET @Skip ROWS FETCH NEXT @Take ROWS This is painfully slow after page 5000+because SQL scans all skipped rows. ✔ REAL FIX: Seek Pagination SELECT TOP (@Take) * FROM Orders WHERE Id > @LastSeenId ORDER BY Id; 💡 Benefit No full scans No offsets Linear, predictable speed
C# “List Reallocations” — Stop Hidden Performance Loss
Large lists cause hidden reallocations: ⚠ Problem When List grows past capacity → reallocates + copies entire array. ✔ Fix Pre-size it: var list = new List<Order>(50000); 💡 Hidden Tip To estimate size: use .Count from previous runs → AUTO-TUNE your list capacity.
C# DTO Mapping Speed Issues — The Hidden Cost of Reflection in AutoMapper
Many devs see slow API responses and blame SQL, not realizing the slowdown is Mapper. ⚠ The Problem AutoMapper uses reflection for complex object graphs.Under load → becomes slow. ✔ Life-Saver Solution Switch to compiled mapping: var config = new MapperConfiguration(cfg => { cfg.CreateMap<User, UserDto>().ConvertUsing(src => new UserDto(src.Id, src.Name)); }); or write your own mapping: […]
C# “Random Freezes” — The REAL Cause: Async → Sync Deadlocks
Developers often write: var result = GetDataAsync().Result; or var result = GetDataAsync().GetAwaiter().GetResult(); This is how 80% of production deadlocks happen. 👉 Why It Deadlocks Async code tries to resume on the captured context (SynchronizationContext).But since you blocked the thread with .Result, it can’t resume → deadlock. ✔ The Fix Make the entire call chain async: […]
Visual Studio “IntelliSense Slow” — Fix the Hidden Roslyn Cache Issue
If IntelliSense lags, it’s usually Roslyn’s temp files. ✔ Fix Delete: %LOCALAPPDATA%\Microsoft\VisualStudio\*\ComponentModelCache Restart VS → Instant improvement. 💡 Bonus Disable unused analyzers for huge solutions.
WordPress “White Screen of Death” — The Real Fix Nobody Mentions
The WSOD usually comes from PHP memory limit — not plugins. ✔ Fix Add to wp-config.php: define(‘WP_MEMORY_LIMIT’, ‘256M’); Default is often 40M → insufficent. 💡 Bonus Enable debug without exposing logs publicly: define(‘WP_DEBUG’, true); define(‘WP_DEBUG_LOG’, true); define(‘WP_DEBUG_DISPLAY’, false);
Windows 11 “File Explorer Slow” — The Thumbnail Cache Killer
The Nightmare: You open a folder, and the green loading bar at the top crawls like a snail. Your icons are blank, the scroll is laggy, and File Explorer feels like it’s running on a computer from 1995. This is rarely a hardware issue; it is almost always a corrupted Thumbnail Cache. The Reason: Windows […]
Windows 11 “Network Freezes” — Fix the Hidden Power Throttling Issue
When Windows aggressively throttles network power, WiFi drops happen. ✔ Fix Disable power throttling: Settings → System → Power → Turn off “Power Throttling”Also run: powercfg -setacvalueindex SCHEME_CURRENT SUB_PROCESSOR PROCTHROTTLEMAX 100 💡 Massive stability boost.
AJAX Cache Nightmare — Why Your GET Requests Don’t Update
Browsers cache GET requests aggressively. ✔ Life-Saving Fix $.ajax({ url: ‘/api/data’, cache: false }); Under the hood, jQuery adds:?_={timestamp} → bypasses cache. 💡 If using fetch: fetch(‘/api/data’, { cache: ‘no-store’ });
JS “Debounce vs Throttle” — Why Your Search Bar Lags
Real problem:Search inputs trigger too many backend calls. ✔ Debounce (use for search) function debounce(fn, delay){ let timeout; return (…args)=>{ clearTimeout(timeout); timeout = setTimeout(()=>fn(…args), delay); }; } ✔ Throttle (use for scroll/resize) function throttle(fn, delay){ let last = 0; return (…args)=>{ const now = Date.now(); if(now – last >= delay){ last = now; fn(…args); } […]
HTML5 “Inputmode” — The Feature That Makes Mobile Forms 10× Better
Most devs don’t know this exists. ✔ Example <input type=”text” inputmode=”numeric” /> This forces numeric keyboard on mobile — even though type is text. Also supports: decimal email search tel url 💡 Immediate UX win.
CSS Flexbox Gap Not Working? — The Hidden Flex Wrapping Trap
gap: only works when flex items wrap correctly. ❌ Wrong .container { display: flex; gap: 20px; flex-wrap: nowrap; } ✔ Correct .container { display: flex; flex-wrap: wrap; gap: 20px; } 💡 Hidden Detail Safari had partial support — updating fixes 90% layout bugs.
Rate Limiting in .NET — Fix ‘Random 429 Errors’ the Right Way
The Trap: Most developers dutifully add a Rate Limiter to their API to prevent abuse. However, they often make a critical mistake: they set a Global Limit. If you set a limit of “1000 requests per minute” globally, a single malicious bot can use up all 1000 requests in 5 seconds. The result? Your legitimate […]
ASP.NET Core “ValidateOnStart” — Stop Production Crashes at Runtime
One of the least known but most powerful features. ✔ Use: builder.Services.AddOptions<MySettings>() .Bind(configuration.GetSection(“MySettings”)) .ValidateDataAnnotations() .ValidateOnStart(); Now, invalid configs fail at startup, not during production traffic. 💡 Saves Hours Prevents: null reference crashes broken API keys missing secrets
SQL Deadlocks — The 3-Lock Pattern That Solves 90% Cases
Deadlocks happen when queries lock different resources in different orders. ✔ The Fix Always lock tables in the same sequence. Example: BEGIN TRAN SELECT … FROM Users WITH (UPDLOCK) SELECT … FROM Orders WITH (UPDLOCK) COMMIT If every stored procedure follows this sequence →deadlocks drop to near zero.
SQL “Slow LIKE Query” — The Real Fix (Not Indexes!)
LIKE ‘%abc%’ is un-indexable — always full scan. ✔ Rarely Known Fix Use a computed column + index: ALTER TABLE Products ADD NameIndex AS LOWER(Name); CREATE INDEX IX_Products_NameIndex ON Products(NameIndex); Query: WHERE NameIndex LIKE ‘%abc%’ 💡 Result Massive speed boost without full scans.
C# “Enum Flags” — The Powerful Feature 90% Underuse
Developers often create multiple boolean columns instead of using bitwise enums. ✔ Correct Pattern [Flags] public enum Permissions { None = 0, Read = 1, Write = 2, Admin = 4 } Check: if (user.Permissions.HasFlag(Permissions.Admin)) { … } 💡 Benefit Reduces: table columns complexity storage condition checks
C# Memory Leaks in LINQ — Why Your App Keeps Eating RAM
LINQ is beautiful but dangerous. ⚠ Root Cause Deferred execution + large collections = hidden leaks. Example: var result = bigList.Where(x => x.IsActive); This doesn’t execute yet — the original list must stay alive. ✔ Fix Materialize immediately: var result = bigList.Where(x => x.IsActive).ToList(); 💡 Life-Saving Detection Tip If RAM grows when iterating lists →you […]
C# “ConfigureAwait(false)” — The Most Misunderstood Performance Trick
Most devs know ConfigureAwait(false)…But few actually know when to use it — or how much performance it saves. ⚠ Problem Default awaits try to resume on the captured context (UI thread / ASP.NET request context).This slows down: high-load async APIs microservices background tasks ✔ Real Fix Use ConfigureAwait(false) in library code, background workers, hosted services: […]
JavaScript Event Loop Misconceptions — Why setTimeout(fn, 0) Is NOT Instant
Many devs think: setTimeout(() => console.log(“hi”), 0); runs immediately. It does NOT. 🔍 Why? It is put into the task queue, which only runs after: microtasks (Promise callbacks) current call stack render steps Example Promise.resolve().then(() => console.log(“promise”)); setTimeout(() => console.log(“timeout”), 0); // Output: // promise // timeout 💡 Why This Matters Debugging race conditions Handling […]
HTML5 Input Validation — Why Your Patterns “Don’t Work”
HTML5 validation fails when: Wrong regex style Missing anchors Using lookaheads (not supported) Using unescaped characters ❌ Wrong <input pattern=”[A-Z]{3}-[0-9]+” /> ✔ Correct Always anchor: <input pattern=”^[A-Z]{3}-[0-9]+$” /> 💡 Life-Saving Detail HTML5 pattern must match the entire string.Not a substring — the whole value. This rule is rarely known and causes hours of debugging.
CSS Z-Index Hell — Why Elements Randomly Disappear (and the Real Fix)
Z-index doesn’t work the way most devs think.It depends on stacking contexts, not numbers. 🔥 The Real Causes position: relative creates a new stacking context transform creates a new stacking context opacity < 1 creates a new stacking context Parent stacking contexts override children You can set z-index: 999999 and STILL not see your element. […]
.NET Core JSON Serializer Pitfalls — Why Your Properties Don’t Serialize
System.Text.Json is fast……but very strict. Common Pain Points Missing getters Private setters PascalCase vs camelCase mismatch Ignored fields without [JsonInclude] Cycles now break serialization ✔ Life-Saving Fix Add: options.PropertyNameCaseInsensitive = true; options.ReferenceHandler = ReferenceHandler.IgnoreCycles; ✔ Hidden Trick For private setters: [JsonInclude] public string Name { get; private set; } This is rarely mentioned but solves […]
ASP.NET Core Middleware Order — Why Your App Breaks for No Reason
The #1 misunderstood part of ASP.NET Core is middleware order. ❌ Bad Order Example app.UseAuthentication(); app.UseRouting(); app.UseAuthorization(); Authentication runs BEFORE routing → user can’t be authorized → random 401s. ✔ Correct Order app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(…); 💡 Life-Saving Insight Routing must ALWAYS come first.Authorization must ALWAYS come after Authentication. Confusing ordering makes APIs randomly break.
SQL The “Too Many Indexes” Problem — Why Over-Indexing Slows Everything
Many devs think more indexes = faster queries.Nope. ⚠ Real Risks Inserts slow down Updates slow down Deletes slow down Database size explodes Memory grants skyrocket Locking increases ✔ The Life-Saving Rule Every index must support a query.If the query does NOT exist → the index should NOT exist. ✔ How To Check Query sys.dm_db_index_usage_stats: […]
SQL Parameter Sniffing — The REAL Fix Nobody Explains Properly
Most “solutions” online are myths.Here’s the real fix. 🧨 The Problem SQL Server caches a plan using the first parameter value. If first call is small dataset → plan optimized for smallIf next call is huge → BAD performance ✔ The Correct Fix (Rarely Understood) Use OPTIMIZE FOR UNKNOWN: SELECT * FROM Orders WHERE CustomerId […]
C# HttpClient Misuse — The Root of Random Slowdowns / DNS Failures
Developers still do this: var client = new HttpClient(); // ❌ NEVER do this Creating HttpClient per request causes: Port exhaustion DNS reuse issues Slowdown under load Socket exceptions ✔ The ONLY Correct Pattern builder.Services.AddHttpClient(); Or for minimal APIs: var client = httpClientFactory.CreateClient(); 💡 The Life-Saving Insight If you see: random timeouts slow downstream calls […]








