Sunday, 15 April 2012

c# - Web API not compressing response content? -



c# - Web API not compressing response content? -

i have webapi , configure compression in webapiconfig:

config.messagehandlers.add(new servercompressionhandler(new gzipcompressor(), new deflatecompressor()));

in winforms client, utilize httpclient this:

webrequesthandler handler = new webrequesthandler() { automaticdecompression = decompressionmethods.gzip | decompressionmethods.deflate, }; client = httpclientfactory.create(new clientcompressionhandler(handler, new gzipcompressor(), new deflatecompressor())); client.baseaddress = new uri(serverurl); client.defaultrequestheaders.acceptencoding.add(new stringwithqualityheadervalue("gzip")); client.defaultrequestheaders.acceptencoding.add(new stringwithqualityheadervalue("deflate")); client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/json"));

both server , client projects reference: https://www.nuget.org/packages/microsoft.aspnet.webapi.messagehandlers.compression/

when create request api, or without using compression, content length same. don't know if content beingness compressed or not.

iis applicationhost.config specific compression looks this:

<httpcompression directory="%temp%\iisexpress\iis temporary compressed files"> <scheme name="gzip" dll="%iis_bin%\gzip.dll" /> <dynamictypes> <add mimetype="text/*" enabled="true" /> <add mimetype="message/*" enabled="true" /> <add mimetype="application/x-javascript" enabled="true" /> <add mimetype="*/*" enabled="false" /> <add mimetype="application/json" enabled="true" /> <add mimetype="application/xml; charset=utf-8" enabled="true" /> </dynamictypes> <statictypes> <add mimetype="text/*" enabled="true" /> <add mimetype="message/*" enabled="true" /> <add mimetype="application/x-javascript" enabled="true" /> <add mimetype="application/atom+xml" enabled="true" /> <add mimetype="application/xaml+xml" enabled="true" /> <add mimetype="*/*" enabled="false" /> </statictypes> </httpcompression>

i checked %temp% folder , there no subfolder named iisexpress, have assume using above config doesn't enabled compression.

is there way check if content compressed before it's beingness deserialized?

and if above code, api compress response? or setting in iis express?

c# asp.net-web-api iis-express

No comments:

Post a Comment