public class BaseController : Controller { /// <summary> /// Called after the action method is invoked. /// </summary> /// <param name="filterContext">Information about the current request and action.</param> protected ov…
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 o…
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace 过滤器.Filtes { /// <summary> /// 全局异常过滤器 /// </summary> public class MyHandleErrorAttribute : HandleErrorAttribute { public over…
重构的乐趣在于精简代码,模块化设计,解耦功能……而对异常处理的重构则刚好满足上述三个方面,下面是我的一点小心得. 一.相关的学习 在文章<精简自己20%的代码>中,讨论了异常的统一处理,并通过对异常处理的封装达到精简代码的目的.具体有两种处理方法: 方法1:封装一个包含try{}catch{}finally{}的异常处理逻辑的方法类,将别的方法作为参数传入该方法,在页面内调用封装后的方法,大体代码如下: public class Process { public static bool Exe…