IIS 配置 GZip

up v20 down vote accepted

I think you should not do this in an action filter as the modelbinding stage happens before action filters are executed and during modelbinding the formatters could be reading the stream to deserialize it, in which case it would fail.

If you are using IIS, then do the following to setup compression(The following have some snippets from Scott Hanselman's blog post):

  • Enabled the "Dynamic Compression" feature in IIS.

  • Back in IIS Manager, go to the page for the SERVER, not the SITE. Click on Configuration Editor:enter image description here

  • From the dropdown, select system.webServer/httpCompression:enter image description here

  • Then click on Dynamic Types and now that you're in the list editor, think about what types you want compressed. By default / is False, but you could just turn that on. I chose to be a little more picky and added application/atom+xml, application/json, and application/atom+xml;charset=utf-8 as seen below. It's a little gotcha that application/atom+xml and application/atom+xml;charset=utf-8 are separate entries. Feel free to add what ever mimeTypes you like in here.enter image description here
  • After you've added them and closed the dialog, be sure to click Apply and Restart your IIS Service to load the new module.
  • Now make requests using Accept-Encoding header and you should see the response as expected.

  • EDIT ( in addition to above include "application/json; charset=utf-8" to cover both json formats)



        





转载于:https://www.cnblogs.com/wuyicqb/p/a7f97d54-be06-43b6-8046-1f697e23fa62.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值