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#

ASP.NET Core Thread Pool Starvation Explained

- 13.12.25 - ErcanOPAK comment on ASP.NET Core Thread Pool Starvation Explained

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.

Read More
Asp.Net Core / C#

ASP.NET Core Logging Slows Your API (Yes, Really)

- 13.12.25 - ErcanOPAK comment on 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

Read More
SQL

SQL Index Exists but Still Not Used? Here’s Why

- 13.12.25 - ErcanOPAK comment on 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.

Read More
SQL

SQL COUNT(*) Is Slower Than You Think

- 13.12.25 - ErcanOPAK comment on 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

Read More
C#

C# ValueTask — The Hidden Performance Weapon

- 13.12.25 | 13.12.25 - ErcanOPAK comment on 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

Read More
C#

C# Dictionary Lookup Slow? You’re Using It Wrong

- 13.12.25 - ErcanOPAK comment on 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

Read More
C#

C# Task.WhenAll Can Kill Your Server (Concurrency Trap)

- 13.12.25 - ErcanOPAK comment on 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 […]

Read More
Visual Studio

VS “Auto-Using Not Working” — The Broken Roslyn Cache Fix

- 12.12.25 - ErcanOPAK comment on 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.

Read More
Wordpress

WP “Plugin Update Breaks Site” — The Rollback Life-Saver

- 12.12.25 - ErcanOPAK comment on 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

Read More
Windows

Windows 11 “SSD Suddenly Slow” — Disabled Write Caching

- 12.12.25 - ErcanOPAK comment on 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.

Read More
Windows

Windows 11 “CPU Stays High for No Reason” — SearchIndexer Loop Bug

- 12.12.25 - ErcanOPAK comment on 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.

Read More
Ajax

AJAX “CORS Works in Postman But Fails in Browser” — Preflight Hell

- 12.12.25 - ErcanOPAK comment on 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.

Read More
JavaScript

JS “Object Mutation Side Effects” — The Hidden Reference Bug

- 12.12.25 - ErcanOPAK comment on 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 };  

Read More
HTML

HTML5 “Form Enter Key Submits Wrong Button” — The Invisible Default Button Rule

- 12.12.25 - ErcanOPAK comment on 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.

Read More
CSS

CSS “Text Overflow Ellipsis Not Working” — The Missing Combo

- 12.12.25 - ErcanOPAK comment on 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.

Read More
Asp.Net Core / C#

.NET Core “Configuration Not Updating” — Missing ReloadOnChange

- 12.12.25 - ErcanOPAK comment on .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).

Read More
Asp.Net Core / C#

ASP.NET Core “Middleware Never Executes” — The Ordering Trap

- 12.12.25 - ErcanOPAK comment on 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.

Read More
SQL

SQL “Dirty Reads & Weird Data” — Fix With SNAPSHOT Isolation

- 12.12.25 - ErcanOPAK comment on 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.

Read More
SQL

SQL “Scalar Functions Destroy Performance” — The Hidden Anti-Pattern

- 12.12.25 - ErcanOPAK comment on 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 ↑.

Read More
C#

C# “Regex Is Slow as Hell” — Missing Compiled Option

- 12.12.25 - ErcanOPAK comment on 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.

Read More
C#

C# “LINQ Select N+1 Disaster” — Why Your Code Makes 500 SQL Calls

- 12.12.25 - ErcanOPAK comment on 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

Read More
C#

C# “HttpClient Freezing Request” — The Hidden Deadlock: Sync-over-Async

- 12.12.25 - ErcanOPAK comment on 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.

Read More
Visual Studio

VS “Breakpoints Hit Wrong Line” — The PDB Stale Cache Bug

- 11.12.25 - ErcanOPAK comment on 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.

Read More
PHP / Wordpress

WP “Menus Not Saving” — The Max Input Vars Killer

- 11.12.25 - ErcanOPAK comment on 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.

Read More
Windows

Windows 11 “Search Bar Broken or Empty” — Rebuild Index the RIGHT Way

- 11.12.25 - ErcanOPAK comment on 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.

Read More
Windows

Windows 11 “UI Stuttering” — The Hidden Hardware Accelerated GPU Scheduling Bug

- 11.12.25 - ErcanOPAK comment on 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.

Read More
Ajax / JavaScript

AJAX “POST Works Locally but Not in Production” — HTTPS Mixed Content

- 11.12.25 - ErcanOPAK comment on 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); // ❌  

Read More
JavaScript

JS “setInterval Drift” — Why Your Timers Run Slower Over Time

- 11.12.25 - ErcanOPAK comment on 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.

Read More
CSS / HTML

HTML5 “Broken Autofill Styles” — Chrome’s Yellow Background Bug

- 11.12.25 - ErcanOPAK comment on 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

Read More
CSS

CSS “Z-Index Doesn’t Work!” — The Parent Stacking Context Curse

- 11.12.25 - ErcanOPAK comment on 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.

Read More
Page 56 of 69
« Previous 1 … 51 52 53 54 55 56 57 58 59 60 61 … 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 (751)
  • 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 (751)

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