关于异常过滤器

u013058975 2017-02-18 03:57:02
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");
}
}
}
...全文
594 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

13,347

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET技术前瞻
社区管理员
  • .NET技术前瞻社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧