首页 > 代码库 > MVC 好记星不如烂笔头之 ---> 页面压缩GIP
MVC 好记星不如烂笔头之 ---> 页面压缩GIP
public class BaseController : Controller{ /// <summary> /// Called before the action method is invoked. /// </summary> /// <param name="filterContext">Information about the current request and action.</param> protected override void OnActionExecuting(ActionExecutingContext filterContext) { foreach (var iBaseService in _iBaseServiceList) { iBaseService.Language = Language; } if (filterContext.HttpContext.Response.Filter == null) return; var acceptEncoding = filterContext.HttpContext.Request.Headers["Accept-Encoding"]; if (String.IsNullOrEmpty(acceptEncoding)) return; var response = filterContext.HttpContext.Response; acceptEncoding = acceptEncoding.ToUpperInvariant(); if (acceptEncoding.Contains("GZIP")) { response.AppendHeader("Content-Encoding", "gzip"); response.Filter = new GZipStream(response.Filter, CompressionMode.Compress); } else if (acceptEncoding.Contains("DEFLATE")) { response.AppendHeader("Content-Encoding", "deflate"); response.Filter = new DeflateStream(response.Filter, CompressionMode.Compress); } base.OnActionExecuting(filterContext); }}
MVC 好记星不如烂笔头之 ---> 页面压缩GIP
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。