0

I try to add header in filter:

 Response.AppendHeader("Content-Encoding", "gzip");

But it is not appears in the browser, not chrome , and not in Firefox:

enter image description here

this is how i return json:

[HttpPost]
public virtual ActionResult GetMetaData()
{

        var result = new BL().GetMetaData();
        string response = JsonConvert.SerializeObject(result, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
        return Content(response, "application/json");

}
ArunPratap
  • 4,816
  • 7
  • 25
  • 43
yantrab
  • 2,482
  • 4
  • 31
  • 52
  • 1
    no gzip-ing is not done by doing `Response.AppendHeader("Content-Encoding", "gzip");` really. read this [answer about http compression on iis](https://stackoverflow.com/a/25580169/4648586) for better understanding. – Bagus Tesa May 10 '18 at 09:56
  • you can't just add a header saying the content is gzipped, if it isn't actually, physically, gzipped. Headers are there to provide information to the recipient, they don't actually _do_ anything. If you want to do this you need to actually zip your content as well, as Bagus mentioned. – ADyson May 10 '18 at 10:08
  • I do compress :Response.Filter = new GZipStream(Response.Filter,CompressionMode.Compress); – yantrab May 10 '18 at 10:25

0 Answers0