How do enable a .Net web-API to accept g-ziped posts

后端 未结 4 1540
别跟我提以往
别跟我提以往 2020-12-08 11:58

I have a fairly bog standard .net MVC 4 Web API application.

 public class LogsController : ApiController
{

    public HttpResponseMessage PostLog(List<         


        
4条回答
  •  执念已碎
    2020-12-08 12:25

    While Web API doesn't support Accept-Encoding header out of the box, but Kiran has a terrific blog post on how to do that - http://blogs.msdn.com/b/kiranchalla/archive/2012/09/04/handling-compression-accept-encoding-sample.aspx - using a custom MessageHandler

    If you implement his solution, all you need to do is issue a request with Accept-Encoding: gzip or Accept-Encoding: deflate header and the Web API response will be compressed in the message handler for you.

提交回复
热议问题