So I'm trying to get my app to send its JSON responses using dynamic compression and gzip. Unfortunately this isn't working. All the static compression on the server is working fine, but not dynamic.
I've set this up by adding:
<add mimeType="application/json" enabled="true" />
<add mimeType="application/json; charset=utf-8" enabled="true" />
To the <dynamicTypes>
section of <httpCompression>
in the applicationHost.config file. I'm using Charles to inspect HTTP requests and I can verify that I'm sending the requests with the Accept-Encoding: gzip, deflate
header set. I've tried with both Accept: */*
and Accept: application/json
. When it wasn't working I enabled 'Failed Request' trace logging to find the error code for DYNAMIC_COMPRESSION_NOT_SUCCESS
, which was NO_MATCHING_CONTENT_TYPE
.
I've been trying to research on forums and Google, but all I can see is people saying that using the mimeType with the charset specified fixes the problem for them, but in my case it's still not working and I can verify that the response comes back with a header saying Content-Type: application/json; charset=utf-8
The endpoints that serve the JSON responses are standard .NET ASMX WebServices annotated with [ScriptService()]
at the class and [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
at the method. They return JSON fine, but I can't get the dynamic compression to work for the life of me.
Since these are regular web methods as well I also added:
<add mimeType="text/xml" enabled="true" />
<add mimeType="text/xml; charset=utf-8" enabled="true" />
To attempt to gzip the XML responses. What's frustrating is that this compression works while sending JSON from the same method doesn't. At this point I'm kindof at a loss.