关于异常过滤器
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Text1.filters;
namespace Text1.Controllers
{
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
throw new Exception("");
}
public ActionResult Show()
{
return View();
}
//protected override void OnAuthorization(AuthorizationContext filterContext)
//{
// //base.OnAuthorization(filterContext);
// filterContext.HttpContext.Response.Write("此处实现验证");
//}
protected override void OnException(ExceptionContext filterContext) //这里重写了异常过滤器的方法,webconfig也进行了配置,为啥Index中抛出的异常还是捕获不到呀?
{
base.OnException(filterContext);
filterContext.Result = new RedirectResult("/Error/400.html");
}
}
}