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 “Request Body Already Read” — Enable Buffering

- 15.12.25 | 16.01.26 - ErcanOPAK comment on ASP.NET Core “Request Body Already Read” — Enable Buffering

Have you ever tried to read the HttpContext.Request.Body in a middleware or a filter, only to find that your API controller receives an empty body? Or worse, your application crashes? By default, the request body is a forward-only stream. Once it’s read, the pointer reaches the end, and there’s nothing left for the next component […]

Read More
Asp.Net Core / C#

ASP.NET Core “Response Compression Not Working” — The Missing MIME Types

- 15.12.25 - ErcanOPAK comment on ASP.NET Core “Response Compression Not Working” — The Missing MIME Types

Compression silently fails without explicit MIME config. ✅ Fix builder.Services.AddResponseCompression(options => { options.MimeTypes = ResponseCompressionDefaults.MimeTypes .Concat(new[] { “application/json” }); });  

Read More
SQL

SQL “DELETE Is Slow” — Use Batch Deletes

- 15.12.25 - ErcanOPAK comment on SQL “DELETE Is Slow” — Use Batch Deletes

Deleting millions of rows at once is dangerous. ❌ DELETE FROM Logs WHERE CreatedAt < ‘2023-01-01’; ✅ Safe Batch Delete WHILE 1 = 1 BEGIN DELETE TOP (1000) FROM Logs WHERE CreatedAt < ‘2023-01-01’; IF @@ROWCOUNT = 0 BREAK; END Why Avoids log explosion Prevents long locks

Read More
SQL

SQL “TOP 1 WITH ORDER BY” Without Index = Full Scan

- 15.12.25 - ErcanOPAK comment on SQL “TOP 1 WITH ORDER BY” Without Index = Full Scan

This query is slow without the right index: SELECT TOP 1 * FROM Orders ORDER BY CreatedAt DESC; ✅ Correct Index CREATE INDEX IX_Orders_CreatedAt ON Orders (CreatedAt DESC); Result Instant response No table scan

Read More
C#

C# Boxing Kills Performance (Without You Noticing)

- 15.12.25 - ErcanOPAK comment on C# Boxing Kills Performance (Without You Noticing)

This looks harmless: List<object> list = new(); list.Add(5); // boxing ✅ Fix Use generics: List<int> list = new(); Why it matters Boxing allocates memory GC pressure increases fast in loops

Read More
C#

C# “Lock Contention” — Why lock(this) Breaks Apps

- 15.12.25 - ErcanOPAK comment on C# “Lock Contention” — Why lock(this) Breaks Apps

This is dangerous: lock(this) { // critical section } ❌ Why it fails External code can also lock on this Deadlocks appear randomly ✅ Correct Pattern private readonly object _sync = new(); lock (_sync) { // safe }  

Read More
C#

C# Async Streams — Stop Loading Huge Lists Into Memory

- 15.12.25 - ErcanOPAK comment on C# Async Streams — Stop Loading Huge Lists Into Memory

If you return large datasets like this: var data = await repository.GetAllAsync(); You already lost memory and latency. ✅ Stream Instead await foreach (var item in repository.StreamAsync()) { Process(item); } Why this is life-saving Near-zero memory footprint Faster first byte Perfect for logs, exports, ETL

Read More
Visual Studio

Visual Studio “F5 Takes Forever” — IIS Express Cache

- 14.12.25 - ErcanOPAK comment on Visual Studio “F5 Takes Forever” — IIS Express Cache

✅ Fix Delete: .vs/ Then restart Visual Studio. Why IIS Express config cache becomes corrupted.

Read More
Wordpress

WordPress Slow First Load — Autoloaded Options Table

- 14.12.25 - ErcanOPAK comment on WordPress Slow First Load — Autoloaded Options Table

Run this: SELECT * FROM wp_options WHERE autoload = ‘yes’; Too many rows = slow site. ✅ Fix Disable autoload on unused options. This alone can cut TTFB in half.

Read More
Windows

Windows 11 Laptop Overheats — Turbo Boost Gone Wrong

- 14.12.25 - ErcanOPAK comment on Windows 11 Laptop Overheats — Turbo Boost Gone Wrong

Turbo Boost causes thermal throttling loops. ✅ Fix Limit max CPU to 99%: Power Options → Processor → Maximum Processor State → 99% Why Disables Turbo without killing performance.

Read More
Windows

Windows 11 Slow Context Menu — The Explorer Extension Trap

- 14.12.25 - ErcanOPAK comment on Windows 11 Slow Context Menu — The Explorer Extension Trap

Third-party shell extensions slow everything. ✅ Fix Disable non-Microsoft extensions using ShellExView. Result Instantly faster right-click menus.

Read More
Ajax / JavaScript

AJAX “Works Once, Then Fails” — Cached POST Response

- 14.12.25 - ErcanOPAK comment on AJAX “Works Once, Then Fails” — Cached POST Response

Some browsers cache aggressively. ✅ Fix fetch(url, { method: ‘POST’, cache: ‘no-store’ }); Especially important for forms authentication dynamic APIs

Read More
JavaScript

JS Memory Leaks — Forgotten Event Listeners

- 14.12.25 - ErcanOPAK comment on JS Memory Leaks — Forgotten Event Listeners

Single-page apps suffer badly from this. ❌ window.addEventListener(‘resize’, handler); ✅ window.removeEventListener(‘resize’, handler); Always clean up listeners on unmount or destroy.

Read More
HTML

HTML5 button Defaults to submit (Surprise!)

- 14.12.25 - ErcanOPAK comment on HTML5 button Defaults to submit (Surprise!)

This causes accidental form submissions. ❌ <button>Click</button> ✅ <button type=”button”>Click</button> Rule Always set the button type explicitly.

Read More
CSS

CSS opacity Breaks Child Elements — Use RGBA Instead

- 14.12.25 - ErcanOPAK comment on CSS opacity Breaks Child Elements — Use RGBA Instead

❌ .card { opacity: 0.8; } This also fades text and icons. ✅ .card { background-color: rgba(0,0,0,0.8); } Why Opacity affects the entire element tree.

Read More
Asp.Net Core / C#

ASP.NET Core Health Checks That Actually Matter

- 14.12.25 - ErcanOPAK comment on ASP.NET Core Health Checks That Actually Matter

Many health checks always return OK. ❌ Useless services.AddHealthChecks(); ✅ Useful services.AddHealthChecks() .AddSqlServer(conn) .AddRedis(redisConn); Why Kubernetes and load balancers rely on this.

Read More
Asp.Net Core / C#

ASP.NET Core “Slow Startup” — Reflection Scanning Trap

- 14.12.25 - ErcanOPAK comment on ASP.NET Core “Slow Startup” — Reflection Scanning Trap

Large projects often scan assemblies repeatedly. ✅ Fix Disable automatic scanning where possible and register explicitly: services.AddScoped<IService, Service>(); Why Reflection is slow at startup — especially in containers.

Read More
SQL

SQL SELECT * — The Hidden Future Bug

- 14.12.25 - ErcanOPAK comment on SQL SELECT * — The Hidden Future Bug

Works today, breaks tomorrow. ❌ SELECT * FROM Users; ✅ SELECT Id, Name, Email FROM Users; Why Schema changes break consumers Pulls unnecessary data Slower network and memory usage

Read More
SQL

SQL “Index Fragmentation Panic” — When NOT to Rebuild

- 14.12.25 - ErcanOPAK comment on SQL “Index Fragmentation Panic” — When NOT to Rebuild

Many rebuild indexes blindly. ❌ Bad Habit ALTER INDEX ALL ON Orders REBUILD; ✅ Smart Rule Fragmentation < 5% → do nothing 5–30% → REORGANIZE 30% → REBUILD ALTER INDEX IX_Orders_Date ON Orders REORGANIZE; Why Rebuild = blocking + log growth.

Read More
C#

C# Exception Handling — The Silent Performance Killer

- 14.12.25 - ErcanOPAK comment on C# Exception Handling — The Silent Performance Killer

Exceptions are expensive.They are not flow control. ❌ try { return dict[key]; } catch { return null; } ✅ return dict.TryGetValue(key, out var value) ? value : null; Rule If it can fail often → do NOT use exceptions.

Read More
C#

C# “foreach Is Slower Than for” — Yes, Sometimes

- 14.12.25 - ErcanOPAK comment on C# “foreach Is Slower Than for” — Yes, Sometimes

On List<T> this matters in tight loops. ❌ foreach (var item in list) { } ✅ Faster for (int i = 0; i < list.Count; i++) { } Why foreach creates an enumerator for is index-based and faster Use this only in hot paths, not everywhere.

Read More
C#

C# Span — The Secret to Zero-Allocation Performance

- 14.12.25 - ErcanOPAK comment on C# Span — The Secret to Zero-Allocation Performance

If you manipulate strings or byte arrays heavily, this matters. ❌ Common Allocation Trap var part = input.Substring(0, 10); ✅ Zero-Allocation Alternative ReadOnlySpan<char> part = input.AsSpan(0, 10); Why this is huge No heap allocation No GC pressure Perfect for parsers and hot paths

Read More
Visual Studio

Visual Studio High CPU When Idle? Live Code Analysis

- 13.12.25 - ErcanOPAK comment on Visual Studio High CPU When Idle? Live Code Analysis

Background analyzers can eat CPU. ✅ Fix Disable unused analyzers: Tools → Options → Text Editor → C# → Advanced Turn off: Full solution analysis

Read More
Wordpress

WordPress Slow Admin Panel? Heartbeat API

- 13.12.25 - ErcanOPAK comment on WordPress Slow Admin Panel? Heartbeat API

WordPress sends frequent AJAX calls. ✅ Fix Install Heartbeat ControlReduce frequency or disable in admin. Result Faster editor Lower CPU usage

Read More
Windows

Windows 11 Micro-Stutters in Apps? Disable MPO

- 13.12.25 - ErcanOPAK comment on Windows 11 Micro-Stutters in Apps? Disable MPO

Multi-Plane Overlay causes flickering and stutter. ✅ Fix (Registry) DisableMPO = 1 (Path: GraphicsDrivers)

Read More
Windows

Windows 11 Laptop Slow on Battery? CPU Throttling

- 13.12.25 - ErcanOPAK comment on Windows 11 Laptop Slow on Battery? CPU Throttling

Windows limits CPU aggressively. ✅ Fix powercfg /setactive SCHEME_MIN Or switch to Best Performance power mode.

Read More
Ajax / JavaScript

AJAX Requests Fail Randomly? CSRF Token Missing

- 13.12.25 - ErcanOPAK comment on AJAX Requests Fail Randomly? CSRF Token Missing

POST requests fail silently without CSRF token. ✅ Fix headers: { ‘X-CSRF-TOKEN’: token } Common victims Laravel Django ASP.NET MVC

Read More
JavaScript

JS “await” Inside forEach Is a Bug

- 13.12.25 - ErcanOPAK comment on JS “await” Inside forEach Is a Bug

This does NOT work: items.forEach(async item => { await process(item); }); ✅ Correct Patterns for (const item of items) { await process(item); } or parallel: await Promise.all(items.map(process));  

Read More
HTML

HTML5 Lazy Loading Without JavaScript

- 13.12.25 - ErcanOPAK comment on HTML5 Lazy Loading Without JavaScript

Stop writing JS for images. <img src=”image.jpg” loading=”lazy” /> Benefits Faster page load Better Core Web Vitals Zero JavaScript

Read More
CSS

CSS 100vh Is Broken on Mobile (Real Fix)

- 13.12.25 - ErcanOPAK comment on CSS 100vh Is Broken on Mobile (Real Fix)

height: 100vh breaks on mobile browsers. ✅ Correct Solution height: 100dvh; Or fallback: min-height: -webkit-fill-available; Why Mobile address bars change viewport height dynamically.

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

Posts pagination

« Previous 1 … 53 54 55 56 57 … 69 Next »
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 (867)
  • Get the First and Last Word from a String or Sentence in SQL (837)
  • How to select distinct rows in a datatable in C# (806)
  • How to make theater mode the default for Youtube (757)
  • 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 (535)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (491)
  • Find numbers with more than two decimal places in SQL (449)

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 (867)
  • Get the First and Last Word from a String or Sentence in SQL (837)
  • How to select distinct rows in a datatable in C# (806)
  • How to make theater mode the default for Youtube (757)

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