using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using cpf360.Common;
using cpf360.DTO; namespace hanli_project.Filters
{
public class HanliExceptionAttribute : IExceptionFilter
{
void IExceptionFilter.OnException(ExceptionContext filterContext)
{
Exception exception = filterContext.Exception;
if (filterContext.ExceptionHandled)
{
return;
} //返回数据
filterContext.Result = new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new OutputData() { data = null, code = -, message = "服务器繁忙" } }; //记录日志
Log4netHelper.LogError(exception); // 设置自定义异常已经处理,避免其他过滤器异常覆盖
filterContext.ExceptionHandled = true; // 在派生类重写时,设置或者重写一个值该值指定是否禁用ISS7.0中自定义错误
filterContext.HttpContext.Response.TrySkipIisCustomErrors = true; }
}
}
using System.Web;
using System.Web.Mvc;
using hanli_project.Filters; namespace hanli_project
{
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
//注册异常过滤器
filters.Add(new HanliExceptionAttribute());
filters.Add(new HandleErrorAttribute());
}
}
}

最新文章

  1. JavaScript的写类方式(6)
  2. Replication的犄角旮旯(五)--关于复制identity列
  3. 数位DP HDU3652
  4. 滚动光效shader
  5. 让PHP 5.3支持MSSQL连接
  6. 百度富文本编辑器UEditor安装配置全过程
  7. PHP CURL访问HTTPS使用详解
  8. 什么是PHP Guzzle?
  9. Wide character in print at hcp.pl line 21.
  10. MVC 使用EF Code First数据迁移之添加字段
  11. 11.hibernate的连接查询
  12. Hibernate锁机制
  13. js判断空值
  14. Angular为什么选择TypeScript?
  15. json文件常用代码
  16. debug错误
  17. Emacs 设置C++代码风格
  18. 视图控制器生命周期中各个重要的方法(Swift) (Important Methods during the Lifecycle of a View Controller)
  19. zookeeper 安装的三种模式
  20. 解决Mac下npm权限问题

热门文章

  1. 【转】Jmeter和LR上传文件和下载
  2. Velodyne 线性激光雷达数据合成
  3. 1046 Shortest Distance
  4. 怎样使用charles抓包
  5. 010. windows10下安装kivy 1.9.1版
  6. Android的按钮单击事件及监听器的实现方式
  7. 用Python语言设计GUI界面
  8. 页面中CSS的四种引入方式的介绍与比较
  9. ffmpeg相关时间概念
  10. Vulkan Tutorial 09 图像与视图