Iis7 compresses dynamic content from a custom handler

I'm having trouble getting dynamic content coming from a custom handler for IIS 7 compression.

Our handler spits out json data (Content-Type: application / json; charset = utf-8) and responds to a url that looks like this: domain.com/example.mal/OperationName?Param1=Val1&Param2=Val2

In IIS 6, all we had to do was edit the MetaBase.xml file and in the IIsCompressionScheme element so that the HcScriptFileExtensions attribute contained the user extension 'mal' in it.

Static and dynamic compression is obtained at the server and website level. I can confirm that normal .aspx pages are compressed correctly. The only content that I cannot compress is the content coming from a custom handler.

I tried the following configurations without success:

<handlers>
  <add name="MyJsonService" verb="GET,POST" path="*.mal" type="Library.Web.HttpHandlers.MyJsonServiceHandlerFactory, Library.Web" />
</handlers>

<httpCompression>
  <dynamicTypes>
    <add mimeType="application/json" enabled="true" />
  </dynamicTypes>
</httpCompression>

_

<httpCompression>
  <dynamicTypes>
    <add mimeType="application/*" enabled="true" />
  </dynamicTypes>
</httpCompression>

_

<staticContent>
  <mimeMap fileExtension=".mal" mimeType="application/json" />
</staticContent>
<httpCompression>
  <dynamicTypes>
    <add mimeType="application/*" enabled="true" />
  </dynamicTypes>
</httpCompression>

Thanks in advance for your help.

+5
source share
1 answer

It looks like this is an error while compressing IIS. I needed to add the following line to the applicationHost.config file (in the httpCompression section) instead of web.config

        <dynamicTypes>
            <add mimeType="application/json; charset=utf-8" enabled="true" />
        </dynamicTypes>

found additional help from here: http://forums.iis.net/p/1162828/1925766.aspx

+5
source

All Articles