Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Author: ErcanOPAK

Asp.Net Core / C#

.NET Core “HttpClient Exhaustion” — Why Your API Suddenly Stops Responding

- 11.12.25 - ErcanOPAK comment on .NET Core “HttpClient Exhaustion” — Why Your API Suddenly Stops Responding

Most devs know not to use new HttpClient(),but they forget the REAL killer: DNS caching. Containers change DNS → HttpClient reuses stale DNS forever. ✔ Fix Use SocketsHttpHandler.PooledConnectionIdleTimeout: builder.Services.AddHttpClient(“api”) .ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler { PooledConnectionIdleTimeout = TimeSpan.FromMinutes(2) }); Prevents DNS poisoning.

Read More
Asp.Net Core

ASP.NET Core “Random 404 After Deploy” — Broken Routing Cache

- 11.12.25 - ErcanOPAK comment on ASP.NET Core “Random 404 After Deploy” — Broken Routing Cache

Kestrel caches endpoints.When you add a new route but deploy without clearing the build output → ghost routes happen. ✔ Fix Add this to .csproj: <PropertyGroup> <DisableFastUpToDateCheck>true</DisableFastUpToDateCheck> </PropertyGroup> Ensures routes rebuild properly every deploy.

Read More
SQL

SQL “Parameter Sniffing Hell” — The REAL Fix Nobody Uses

- 11.12.25 - ErcanOPAK comment on SQL “Parameter Sniffing Hell” — The REAL Fix Nobody Uses

When SQL caches a plan for one specific parameter, other queries become slow. Most people use OPTION RECOMPILE.BUT the REAL fix? ✔ Create an optimized local variable DECLARE @local INT = @UserId; SELECT … WHERE UserId = @local; SQL can no longer sniff the parameter → balanced plan for all users.

Read More
Development / SQL

SQL “Zombie TempDB” — The Invisible Performance Killer

- 11.12.25 - ErcanOPAK comment on SQL “Zombie TempDB” — The Invisible Performance Killer

TempDB grows silently until EVERYTHING slows. ✔ Fix: Right-size files ALTER DATABASE tempdb MODIFY FILE (NAME=’tempdev’, SIZE=4GB); And create multiple TempDB files: 4–8 files = massive improvement 💡 Why? TempDB is used for: joins sorting hashing version store This tweak alone boosts 90% of sluggish systems.

Read More
C#

C# “DateTime.Now Is Lying to You” — The Hidden Clock Skew Bug

- 11.12.25 - ErcanOPAK comment on C# “DateTime.Now Is Lying to You” — The Hidden Clock Skew Bug

Microservices deployed across containers = clock drifting. DateTime.Now can differ by 1-4 seconds between services → token validation fails → weird 401 errors. ✔ Use: DateTime.UtcNow Even better: ISystemClock clock 💡 Hidden Detail JWT validation is extremely sensitive to skew.Use: ClockSkew = TimeSpan.FromMinutes(2)  

Read More
C#

C# Memory Leak: Event Handlers Never Unsubscribe

- 11.12.25 - ErcanOPAK comment on C# Memory Leak: Event Handlers Never Unsubscribe

The classic leak: service.OnData += Handler; If you never do: service.OnData -= Handler; your entire object stays in memory FOREVER. ✔ Life-Saving Pattern using var reg = service.OnData.Register(Handler); Self-disposing event registration.Almost nobody uses this but it prevents weeks-long debugging nightmares.

Read More
C# / LINQ

C# “Async LINQ Disaster” — Why Your Parallel Queries Freeze Your App

- 11.12.25 | 11.12.25 - ErcanOPAK comment on C# “Async LINQ Disaster” — Why Your Parallel Queries Freeze Your App

Developers commonly mix async with LINQ: var results = items.Select(async x => await Process(x)); await Task.WhenAll(results); Looks correct, right?Nope. This triggers thousands of async state machines, killing perf. await Parallel.ForEachAsync(items, async (item, ct) => { await Process(item); }); 💡 Why It Saves You uses shared workers avoids micro-task explosion predictable throughput

Read More
Visual Studio

VS “Debugger Attached But Breakpoints Skip” — The Optimization Trap

- 09.12.25 - ErcanOPAK comment on VS “Debugger Attached But Breakpoints Skip” — The Optimization Trap

If breakpoints turn hollow → VS cannot attach because JIT optimized code away. ✔ Fix Project → Properties → Build → Uncheck “Optimize code”Then: Clean → Rebuild → Restart VS 💡 Hidden Tip Also ensure: Debug → Options → Enable Just My Code  

Read More
Wordpress

WP “Permalinks Not Working” — The .htaccess Rewrite Reset

- 09.12.25 - ErcanOPAK comment on WP “Permalinks Not Working” — The .htaccess Rewrite Reset

Sometimes WP permalinks break silently. ✔ Fix Go to:Settings → Permalinks → Save (without changing) This regenerates .htaccess with: # BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress Instant fix.

Read More
Windows

Windows 11 “VPN Slow After Update” — Broken MTU

- 09.12.25 - ErcanOPAK comment on Windows 11 “VPN Slow After Update” — Broken MTU

Windows updates sometimes reset MTU to a suboptimal value. ✔ Detect: ping google.com -f -l 1472 Reduce until no fragmentation. ✔ Apply Fix: netsh interface ipv4 set subinterface “Ethernet” mtu=1400 store=persistent  

Read More
Windows

Windows 11 “Alt-Tab Lag” — The Explorer Restart Trick

- 09.12.25 - ErcanOPAK comment on Windows 11 “Alt-Tab Lag” — The Explorer Restart Trick

Alt-Tab becomes slow due to animation caching. ✔ Fix: taskkill /IM explorer.exe /F start explorer.exe Refreshes UI animation buffers.

Read More
Ajax / JavaScript

AJAX “POST Suddenly Fails” — The Missing Content-Type Header

- 09.12.25 - ErcanOPAK comment on AJAX “POST Suddenly Fails” — The Missing Content-Type Header

Many backends reject requests silently. ✔ Fix: $.ajax({ method: “POST”, url: “/api/data”, contentType: “application/json”, data: JSON.stringify({ id: 1 }) }); Missing contentType = backend can’t parse payload.

Read More
JavaScript

JS “Undefined Errors in Loops” — The Closure Trap

- 09.12.25 - ErcanOPAK comment on JS “Undefined Errors in Loops” — The Closure Trap

Typical bug: for (var i = 0; i < 5; i++) { setTimeout(() => console.log(i), 100); } Output: 5 5 5 5 5 Because var is function-scoped. ✔ Fix for (let i = 0; i < 5; i++) { setTimeout(() => console.log(i), 100); } Or: setTimeout(((x)=>()=>console.log(x))(i), 100);  

Read More
HTML

HTML5 Input “step=any” — The Secret to Fix Broken Decimal Validation

- 09.12.25 - ErcanOPAK comment on HTML5 Input “step=any” — The Secret to Fix Broken Decimal Validation

Developers struggle with inputs like: <input type=”number” step=”0.01″ /> But values like 0.333 fail. ✔ Fix Allow any decimal: <input type=”number” step=”any” /> 💡 Works beautifully for: currency measurements percentages

Read More
CSS

CSS “Absolute Element Misaligned” — The position: relative Curse

- 09.12.25 - ErcanOPAK comment on CSS “Absolute Element Misaligned” — The position: relative Curse

Absolute positioned child needs a positioned parent. ❌ Wrong .parent { } .child { position: absolute; top: 10px; } ✔ Correct .parent { position: relative; } .child { position: absolute; top: 10px; } 💡 Hidden Trap Transforms also create new positioning contexts.

Read More
Asp.Net Core / C#

.NET Core “Kestrel Timeout” — The Hidden Request Body Limit

- 09.12.25 - ErcanOPAK comment on .NET Core “Kestrel Timeout” — The Hidden Request Body Limit

Many APIs fail mysteriously with: “Unexpected end of request content.” Because the request body timeout is too low. ✔ Fix builder.WebHost.ConfigureKestrel(o => { o.Limits.RequestBodyTimeout = TimeSpan.FromMinutes(5); }); 💡 Life-Saver For: file uploads slower mobile clients integrations with old systems

Read More
Asp.Net Core / C#

ASP.NET Core “IOptions Snapshot Turns Slow” — The Startup Misuse

- 09.12.25 - ErcanOPAK comment on ASP.NET Core “IOptions Snapshot Turns Slow” — The Startup Misuse

Calling IOptionsSnapshot in tight loops = performance disasterbecause it reconstructs objects every request. ✔ Fix Use IOptionsMonitor for high-frequency reads. public MyService(IOptionsMonitor<MyConfig> cfg) { _cfg = cfg; } Monitor is cached, Snapshot is per-request.

Read More
SQL

SQL “Blocking Chains” — The Magic of READPAST

- 09.12.25 - ErcanOPAK comment on SQL “Blocking Chains” — The Magic of READPAST

Ever seen queries freeze because a row is locked? Use the magical, rarely-used hint: SELECT * FROM Orders WITH (READPAST) WHERE Status = ‘Pending’; This skips locked rows instead of waiting. ✔ Perfect for: Queue tables Background workers Batch processors

Read More
SQL

SQL “High CPU for No Reason” — The Missing Statistics Update

- 09.12.25 - ErcanOPAK comment on SQL “High CPU for No Reason” — The Missing Statistics Update

Sometimes SQL goes to 80–90% CPU “out of nowhere”because stats are stale. ✔ Emergency Fix: UPDATE STATISTICS Orders WITH FULLSCAN; 💡 Why It Works The optimizer chooses WILDLY wrong plans if statistics aren’t fresh. ⚠ Pro Tip If your DB is huge → don’t FULLSCAN often.Use: EXEC sp_updatestats; Much lighter.

Read More
C#

C# “JsonSerializer Ignores Private Setters” — The Missing Attribute

- 09.12.25 - ErcanOPAK comment on C# “JsonSerializer Ignores Private Setters” — The Missing Attribute

System.Text.Json does not serialize properties with private setters unless marked. ✔ Fix: [JsonInclude] public string Name { get; private set; } 💡 Hidden Trick This works even when constructor injection is used — extremely useful for DDD entities.

Read More
C#

C# “Background Task Randomly Stops” — Lost Exceptions in Fire-and-Forget

- 09.12.25 - ErcanOPAK comment on C# “Background Task Randomly Stops” — Lost Exceptions in Fire-and-Forget

The classic mistake: Task.Run(() => DoWork()); Exceptions inside fire-and-forget tasks are lost forever → task silently dies. ✔ Correct Pattern _ = Task.Run(async () => { try { await DoWork(); } catch (Exception ex) { logger.LogError(ex, “Background task failed”); } }); 💡 Why This Saves Lives Silent exceptions = random missing jobs.

Read More
C#

C# “StringBuilder Turns Slow” — The Hidden Capacity Trap

- 09.12.25 - ErcanOPAK comment on C# “StringBuilder Turns Slow” — The Hidden Capacity Trap

Everyone uses StringBuilder for speed…but almost nobody knows WHY it becomes slow after heavy use. ⚠ Problem When StringBuilder grows beyond its internal buffer → it doubles memory and copies everything.Large loops = huge perf waste. ✔ Life-Saving Fix var sb = new StringBuilder(50000); // pre-allocate If you know approximate size → pre-allocating saves massive […]

Read More
Visual Studio

Visual Studio “Build Never Stops” — The Rogue MSBuild Node Issue

- 08.12.25 - ErcanOPAK comment on Visual Studio “Build Never Stops” — The Rogue MSBuild Node Issue

Sometimes build gets stuck forever at 0%. ✔ Life-Saving Fix taskkill /IM MSBuild.exe /F taskkill /IM VBCSCompiler.exe /F Restart VS → build works instantly. 💡 Why It Happens Zombie MSBuild nodes fail to unload.

Read More
Wordpress

WordPress “Images Not Updating” — The Persistent Cache Trap

- 08.12.25 - ErcanOPAK comment on WordPress “Images Not Updating” — The Persistent Cache Trap

Even if you upload a new image, WP serves the cached thumbnail. ✔ Fix Delete old thumbnails: /wp-content/uploads/YYYY/MM/imagename-*x*.jpg Then regenerate thumbnails using plugin: ✨ Regenerate Thumbnails. Instant fix for “image not updating” issues.

Read More
Windows

Windows 11 “High RAM Usage After Sleep” — Memory Compression Bug

- 08.12.25 - ErcanOPAK comment on Windows 11 “High RAM Usage After Sleep” — Memory Compression Bug

Windows sometimes never releases compressed memory. ✔ Fix Run: powershell -command “Disable-MMAgent -mc” powershell -command “Enable-MMAgent -mc” Resets memory manager without reboot.

Read More
Windows

Windows 11 “Audio Crackling” — The Hidden CPU Scheduling Bug

- 08.12.25 - ErcanOPAK comment on Windows 11 “Audio Crackling” — The Hidden CPU Scheduling Bug

This happens on systems using: Realtek chips Low latency settings CPU parking ✔ Fix Disable MMCSS Audio Throttling: reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Audio /v DisableMMCSS /t REG_DWORD /d 1 /f Restart → audio becomes crystal clear.

Read More
Ajax / JavaScript

AJAX “Stale Data” — Browser Caching GET Requests Deeply

- 08.12.25 - ErcanOPAK comment on AJAX “Stale Data” — Browser Caching GET Requests Deeply

Even server changes don’t update responses. ✔ Fix $.ajax({ url: “/api/data”, cache: false }); or fetch: fetch(“/api/data”, { cache: “no-store” }); Instantly fixes “old response stuck” issue.

Read More
JavaScript

JS “Unexpected NaN” — The Invisible Type Coercion Trap

- 08.12.25 - ErcanOPAK comment on JS “Unexpected NaN” — The Invisible Type Coercion Trap

Common bug: “5” – “2” // works => 3 “5” + “2” // ’52’ “5” * “hi” // NaN JS coerces AND behaves inconsistently. ✔ Life-Saving Fix Always convert: Number(value) or parseInt(value, 10) 💡 Bonus Trap parseInt(“08”) returns 8 but “08” == 8 is true → chaos.

Read More
HTML

HTML5 Video Autoplay Failing? — The REAL Browser Requirement

- 08.12.25 - ErcanOPAK comment on HTML5 Video Autoplay Failing? — The REAL Browser Requirement

Chrome, Safari, Firefox → all require muted autoplay. ✔ Correct Way <video autoplay muted playsinline> <source src=”video.mp4″ type=”video/mp4″> </video> If muted is missing → autoplay is blocked. 💡 Mobile Tip Add playsinline to avoid fullscreen takeover.

Read More
CSS

CSS Grid “Overflow Bug” — When Your Layout Randomly Breaks

- 08.12.25 - ErcanOPAK comment on CSS Grid “Overflow Bug” — When Your Layout Randomly Breaks

If a grid child is bigger than the track → grid collapses. ✔ Life-Saving Fix Add: min-width: 0; min-height: 0; ⚠ Why? CSS Grid defaults are NOT zero — they try to preserve content size.This breaks responsive layouts.

Read More
Page 57 of 69
« Previous 1 … 52 53 54 55 56 57 58 59 60 61 62 … 69 Next »

Posts navigation

Older posts
Newer posts
April 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Mar    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (858)
  • Get the First and Last Word from a String or Sentence in SQL (836)
  • How to select distinct rows in a datatable in C# (805)
  • How to make theater mode the default for Youtube (754)
  • Add Constraint to SQL Table to ensure email contains @ (578)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (564)
  • Average of all values in a column that are not zero in SQL (531)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (489)
  • Find numbers with more than two decimal places in SQL (447)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries
  • SQL: Use Window Functions for Advanced Analytical Queries
  • .NET Core: Use Background Services for Long-Running Tasks
  • .NET Core: Use Minimal APIs for Lightweight HTTP Services
  • Git: Use Cherry-Pick to Apply Specific Commits Across Branches
  • Git: Use Interactive Rebase to Clean Up Commit History Before Merge

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (858)
  • Get the First and Last Word from a String or Sentence in SQL (836)
  • How to select distinct rows in a datatable in C# (805)
  • How to make theater mode the default for Youtube (754)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com