locked
Decompressing Web Api response RRS feed

  • Question

  • User715841376 posted

    I am compressing web Api responses with following config

    <system.webServer>
    <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
      <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
      <dynamicTypes>
        <add mimeType="text/*" enabled="true" />
        <add mimeType="application/*" enabled="true" />
        <add mimeType="*/*" enabled="false" />
      </dynamicTypes>
      <staticTypes>
        <add mimeType="text/*" enabled="true" />
        <add mimeType="application/*" enabled="true" />
        <add mimeType="*/*" enabled="false" />
      </staticTypes>
    </httpCompression>
    <urlCompression doStaticCompression="true" doDynamicCompression="true" />

    Now when i consume this in a Win Form applications and try to do the follwoing

    var rawData = await response.Content.ReadAsStringAsync();
                       var deserializedData = JsonConvert.DeserializeObject<Employees[]>(rawData).ToList();

    it fails on

    var deserializedData = JsonConvert.DeserializeObject(rawData).ToList();

    the Error message is

    {"Unexpected character encountered while parsing value: . Path '', line 0, position 0."}

    I guess this is due to the fact that content is gziped and not being deserialized. Can anyone suggest a solution ? This works locally fine as local IIS is not gzip enabled

    Monday, July 13, 2015 9:33 AM

Answers

All replies