想自定义错误,代码如下:
protected void Application_Error(object sender, EventArgs e) { Exception ex = Server.GetLastError(); if (ex is HttpException) { if (((HttpException)(ex)).GetHttpCode() == 404) { } Server.Transfer("~/Error/PageNotFound"); }
不管用啊?
mvc中,可以声明一个类,继承HandleErrorAttribute,处理异常错误,在 global文件中RegisterGlobalFilters,实现自己全局filter