Let's say I have a large string that I want write to the Response Body. I can use a sample like this one below:
var largeString = System.Text.Encoding.UTF8.GetBytes("A very large string content"); await Response.Body.WriteAsync(largeString, 0, largeString.Length);
Now, I would like to Compress the largeString using gzip compression and set appropriate headers
Response.Headers.Add("Content-Encoding", "gzip");
What's the right way to do gzip and write to the Response body that the browser can understand?
Thanks!