我没有得到我的异常处理命中时,我有压缩过滤器的行动,他们是一个错误。请求未返回响应。如果我删除压缩过滤器,那么它返回的错误数组就可以了。我怎样才能跳过一个错误的压缩过滤器,或者让它第二次命中?
[HttpPost, CompressAttribute]
public virtual ActionResult Builder()
全球.asax
GlobalConfiguration.Configuration.Filters.Add(new ExceptionHandlingAttribute());
压缩过滤器
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
public class CompressAttribue : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var encodingsAccepted = filterContext.HttpContext.Request.Headers["Accept-Encoding"];
if (string.IsNullOrEmpty(encodingsAccepted)) return;
encodingsAccepted = encodingsAccepted.ToLowerInvariant();
var response = filterContext.HttpContext.Response;
if (encodingsAccepted.Contains("gzip"))
{
response.AppendHeader("Content-encoding", "gzip");
response.Filter = new GZipStream(response.Filter, CompressionMode.Compress);
}
else if (encodingsAccepted.Contains("deflate"))
{
response.AppendHeader("Content-encoding", "deflate");
response.Filter = new DeflateStream(response.Filter, CompressionMode.Compress);
}
}
}