In IIS7, I turned on dynamic compression at the app level for my ASP.NET MVC application. Afterwards, I traced the app with fiddler and compression is not happening on JSON responses . Has anyone gotten IIS 7 compression to work with mvc controller calls
that return JSON? I noticed some folks rolled their own action filters to implement compression in their mvc apps but this looks more painful and less configurable than IIS compression.
Appears IIS7 does not compress JSON by default (would be nice if it did). Apparently, you have to edit apphost.config directly (notepad is your best bet on 64 bit systems) or indirectly (use appcmd.exe) to instruct IIS to compress responses with the JSON
mime type.
skmcfadden
Member
35 Points
97 Posts
mvc compression in IIS7?
Dec 03, 2009 06:12 PM|LINK
In IIS7, I turned on dynamic compression at the app level for my ASP.NET MVC application. Afterwards, I traced the app with fiddler and compression is not happening on JSON responses . Has anyone gotten IIS 7 compression to work with mvc controller calls that return JSON? I noticed some folks rolled their own action filters to implement compression in their mvc apps but this looks more painful and less configurable than IIS compression.
thanks!
compression IIS mvc
Augi
Contributor
6730 Points
1142 Posts
Re: mvc compression in IIS7?
Dec 03, 2009 06:59 PM|LINK
Are you sure that you are sending valid "Accept-encoding" HTTP header value? Try to check this thread: http://stackoverflow.com/questions/786638/how-can-i-get-gzip-compression-in-iis7-working
skmcfadden
Member
35 Points
97 Posts
Re: mvc compression in IIS7?
Dec 03, 2009 08:43 PM|LINK
Yes.
Relevant parts of my request:
Accept: application/json, text/javascript, */*
Accept-Encoding: gzip,deflate,sdch
<div>
<div></div>
</div>
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Accept: application/json, text/javascript, */*</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">Accept-Encoding: gzip,deflate,sdch</div> <div></div>skmcfadden
Member
35 Points
97 Posts
Update
Dec 03, 2009 09:35 PM|LINK
Appears IIS7 does not compress JSON by default (would be nice if it did). Apparently, you have to edit apphost.config directly (notepad is your best bet on 64 bit systems) or indirectly (use appcmd.exe) to instruct IIS to compress responses with the JSON mime type.
http://forums.iis.net/p/1155809/1895877.aspx
http://weblogs.asp.net/owscott/archive/2009/02/22/iis-7-compression-good-bad-how-much.aspx
http://technet.microsoft.com/en-us/library/cc771003(WS.10).aspx
json compression IIS7
ricka6
All-Star
15070 Points
2272 Posts
Microsoft
Moderator
Re: Update
Dec 03, 2009 11:58 PM|LINK
skmcfadden - Thanks for posting this, I'll add it to the MVC FAQ
The first link says it all, you are correct.