i using asmx web service , calling through ajax as
$.ajax({ url: 'xxxxxxx.asmx/getxxxxxxxx', method: 'post', contenttype: 'application/json; charset=utf-8', datatype: 'json', success: function (data) { $(data.d).each(function (index, category) {
my service returns list of objects. reading on how compress response of web service , seems me need override getwebrequest method , use gzip/deflate (in class derived web service proxy class).
the next step use instance of class (which overrides getwebrequest) , use in application.
since, using ajax call, not sure how use instance of class overrides getwebrequest method.
thank you.
in order send compressed response client, web-service, must using content-encoding field , set value compress.
content-encoding: gzip
but, before must check value of "accept-encoding" header send client. possible values header
accept-encoding: compress, gzip accept-encoding: accept-encoding: * accept-encoding: compress;q=0.5, gzip;q=1.0 accept-encoding: gzip;q=1.0, identity; q=0.5, *;q=0
the above mentioned guidelines applicable, irrespective of whatever language/technology using.
for more information of http protocol headers, refer
https://www.w3.org/protocols/rfc2616/rfc2616-sec14.html
edit
"accept-encoding" request header must set in ajax request. can that, setting "headers" in ajax request follow :
$.ajax({ url: 'xxxxxxx.asmx/getxxxxxxxx', method: 'post', contenttype: 'application/json; charset=utf-8', datatype: 'json', headers: { "my-first-header":"first value", "my-second-header":"second value" } success: function (data) {} });
Comments
Post a Comment