<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-http-chunked-encoding-was-killing-a-request-ojeaa9xgb" -->

---
title: How HTTP Chunked Encoding was killing a request | daily.dev
description: A debugging story walks through diagnosing a 16-second ASP.NET MVC request that returned JSON over chunked transfer encoding. Using Fiddler and JetBrains...
canonical: https://daily.dev/posts/how-http-chunked-encoding-was-killing-a-request-ojeaa9xgb
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How HTTP Chunked Encoding was killing a request | daily.dev
og:description: A debugging story walks through diagnosing a 16-second ASP.NET MVC request that returned JSON over chunked transfer encoding. Using Fiddler and JetBrains...
og:url: https://daily.dev/posts/how-http-chunked-encoding-was-killing-a-request-ojeaa9xgb
og:image: https://api.daily.dev/og/posts/ojeaA9xGB.png
og:image:alt: How HTTP Chunked Encoding was killing a request
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How HTTP Chunked Encoding was killing a request

**[Maarten Balliauw](https://daily.dev/sources/maartenballiauw)** · 9 min read · 0 upvotes · 0 comments

## Summary

A debugging story walks through diagnosing a 16-second ASP.NET MVC request that returned JSON over chunked transfer encoding. Using Fiddler and JetBrains dotTrace, the investigation traces the slowdown to the ExplicitFlush method in System.Web.Hosting.IIS7WorkerRequest, which performs a PInvoke call into native IIS code on every single JSON token write because response.BufferOutput was set to false. The fix was to stop using chunked encoding (since response sizes were small, a few hundred KB max) and instead buffer and return the JSON as a plain string, dropping response time from 12-16 seconds to 450ms.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.maartenballiauw.be/posts/2018-06-14-how-http-chunked-encoding-was-killing-a-request>

## Questions this post answers

### Why is my ASP.NET MVC chunked response so slow even though the payload is small?

Setting response.BufferOutput = false to enable chunked transfer encoding causes every single write call (even a single JSON token) to trigger a flush through StreamWriter, which calls System.Web.Hosting.IIS7WorkerRequest.ExplicitFlush. That method makes a PInvoke call into native IIS code on every flush, and PInvoke overhead on thousands of tiny writes can turn a sub-second response into 12-16 seconds.

_daily.dev surfaces deep debugging writeups like this for developers chasing down ASP.NET performance regressions._

### How do I fix slow flushing when writing JSON with JsonTextWriter and StreamWriter in ASP.NET?

Two fixes work: set AutoFlush = false on the StreamWriter to stop flushing on every write, or avoid chunked encoding entirely by buffering the JSON into a string with JsonConvert.SerializeObject and returning it as normal content when the payload size is known to be small. The second approach dropped one request from 12-16 seconds down to 450ms.

_Developers tuning ASP.NET response streaming can track fixes like this through daily.dev._

## Similar posts on daily.dev

- [Understanding the worst .NET vulnerability ever: request smuggling and CVE-2025-55315](https://daily.dev/posts/understanding-the-worst-net-vulnerability-ever-request-smuggling-and-cve-2025-55315-qljqff7f0) · .NET Escapades · 8 upvotes · 0 comments
- [Why ASP.NET Core Feels Fast Locally but Slow in Production](https://daily.dev/posts/why-asp-net-core-feels-fast-locally-but-slow-in-production-mtgpu8lqk) · C\# Corner · 42 upvotes · 0 comments
- [Today I will… find hidden latency across a distributed .NET application](https://daily.dev/posts/today-i-will-find-hidden-latency-across-a-distributed-net-application-37hqr8by1) · Visual Studio Blog · 8 upvotes · 0 comments
- [Streaming AI responses and the incomplete JSON problem](https://daily.dev/posts/streaming-ai-responses-and-the-incomplete-json-problem-m5qu38ueg) · RUBYLAND · 2 upvotes · 0 comments
- [Capturing HTTP Request and Response Bodies in .NET Traces with PHI Redaction](https://daily.dev/posts/capturing-http-request-and-response-bodies-in-net-traces-with-phi-redaction-anqr488g5) · Last9 · 6 upvotes · 1 comments

---

Tags: [#performance](https://daily.dev/tags/performance)

[View this post on daily.dev](https://daily.dev/posts/how-http-chunked-encoding-was-killing-a-request-ojeaa9xgb)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How HTTP Chunked Encoding was killing a request","url":"https://daily.dev/posts/how-http-chunked-encoding-was-killing-a-request-ojeaa9xgb","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-http-chunked-encoding-was-killing-a-request-ojeaa9xgb"},"datePublished":"2026-10-04T13:04:29.006Z","dateModified":"2026-10-04T13:08:02.685Z","description":"A debugging story walks through diagnosing a 16-second ASP.NET MVC request that returned JSON over chunked transfer encoding. Using Fiddler and JetBrains...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/b6e6761d76cc2192897cc8ec40c4db23?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/b6e6761d76cc2192897cc8ec40c4db23?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Maarten Balliauw","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Maarten Balliauw","logo":"https://media.daily.dev/image/upload/s--rOTg3VYO--/f_auto,q_auto/v1791119043/logos/maartenballiauw?_a=BAMAMicg0","url":"https://daily.dev/sources/maartenballiauw"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-http-chunked-encoding-was-killing-a-request-ojeaa9xgb","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"performance","timeRequired":"PT9M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Maarten Balliauw","item":"https://daily.dev/sources/maartenballiauw"},{"@type":"ListItem","position":3,"name":"How HTTP Chunked Encoding was killing a request"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-http-chunked-encoding-was-killing-a-request-ojeaa9xgb#faq","mainEntity":[{"@type":"Question","name":"Why is my ASP.NET MVC chunked response so slow even though the payload is small?","acceptedAnswer":{"@type":"Answer","text":"Setting response.BufferOutput = false to enable chunked transfer encoding causes every single write call (even a single JSON token) to trigger a flush through StreamWriter, which calls System.Web.Hosting.IIS7WorkerRequest.ExplicitFlush. That method makes a PInvoke call into native IIS code on every flush, and PInvoke overhead on thousands of tiny writes can turn a sub-second response into 12-16 seconds. daily.dev surfaces deep debugging writeups like this for developers chasing down ASP.NET performance regressions."}},{"@type":"Question","name":"How do I fix slow flushing when writing JSON with JsonTextWriter and StreamWriter in ASP.NET?","acceptedAnswer":{"@type":"Answer","text":"Two fixes work: set AutoFlush = false on the StreamWriter to stop flushing on every write, or avoid chunked encoding entirely by buffering the JSON into a string with JsonConvert.SerializeObject and returning it as normal content when the payload size is known to be small. The second approach dropped one request from 12-16 seconds down to 450ms. Developers tuning ASP.NET response streaming can track fixes like this through daily.dev."}}]}
```

