Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC4 WebAPI not compressing GET responses

I'm working on a project that uses the MVC4 WebAPI (RC). The responses are not gzip compressed (dynamic compression in IIS is enabled).

The responses from normal MVC controllers are compressed. Do I need a specific setting to enable gzip compression for WebAPI responses?

I could add a custom compression handler, but if possible, I would just like to use the built-in IIS compression.

BTW, I know this is almost a duplicate of Compress HTTP GET Response, however the accepted answer there doesn't really answer my question.

like image 332
Carvellis Avatar asked Jun 08 '12 13:06

Carvellis


1 Answers

Is dynamic compression enabled for mimetype application/json; charset=utf-8? By default this is not enabled even if dynamic compression is enabled.

To see if it is enabled, you can look in the applicationhost.config file under %windir%\System32\inetsrv\config in the section.

You should not edit the file, instead use appcmd.exe to change it like this: https://stackoverflow.com/a/7375645/243936

like image 146
Eivind T Avatar answered Oct 05 '22 06:10

Eivind T