Reputation: 941
I am building a RESTful services using web api. My client is a HTML5/Jquery application. The service and application works perfectly on IIS 5.1. But when i switch to IIS 7.5, i see the response contains a Transfer-Encoding: chunked header and my client doesn't understand/render UI elements(btw this HTML 5/JQuery stuff is done by a third party and i don't want to change their code. why should i ? after all, it was working fine till we moved to IIS 7.5). My questions are :
When i access the service from browser/fiddler i get the proper response(xml/json). I am using Json.net formatter.
Upvotes: 3
Views: 3829
Reputation: 81
This could be due to this bug which is fixed post-beta:
"DevDiv 388456 -- WebHost should not use Transfer-Encoding chunked when content length is known" http://aspnetwebstack.codeplex.com/SourceControl/changeset/changes/06f52b894414#src%2fSystem.Web.Http.WebHost%2fHttpControllerHandler.cs
Setting response.Headers.TransferEncodingChunked = false; didn't work around this issue for me.
Also you are likely to apparently be getting different results in Fiddler due to having "Decode" button pressed at the top which automatically de-chunks the response and removes the transfer-encoding header from the response.
Upvotes: 1
Reputation: 81700
Use
myHttpResponseMessage.Headers.TransferEncodingChunked = false;
to turn off chunked encoding.
Upvotes: 1