views:

303

answers:

1

I am having trouble getting dynamic content coming from a custom handler to be compressed by IIS 7.

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

In IIS 6, all we had to do was put the edit the MetaBase.xml and in the IIsCompressionScheme element make sure that the HcScriptFileExtensions attribute had the custom extension 'mal' included in it.

Static and Dynamic compression is turned out at the server and website level. I can confirm that normal .aspx pages are compressed correctly. The only content I cannot have compressed is the content coming from the custom handler.

I have tried the following configs with no 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 the help.

+3  A: 

looks like it is a bug in the IIS compression. I needed to add the following line to the applicationHost.config file (under httpCompression ) instead of the web.config

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

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

Malloc
+1, but you should mention the difference that `charset=utf-8` makes, needed because of the IIS parsing bug mentioned in the thread you link to
orip