码迷,mamicode.com
首页 > Web开发 > 详细

ASP.NET MVC中错误处理方式

时间:2017-10-18 14:10:55      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:csharp   参考   asp   exception   out   处理   ted   asp.net   div   

/// <summary>
        /// 标记了HandleError,并指明错误处理页为AboutError.aspx
        /// </summary>
        /// <returns></returns>
        [HandleError(View = "AboutError")]
        public ActionResult About()
        {
            return View();
        }

 重写OnException

protected override void OnException(ExceptionContext filterContext)
        {
            // 标记异常已处理
            filterContext.ExceptionHandled = true;
            // 跳转到错误页
            filterContext.Result = new RedirectResult(Url.Action("Error", "Shared"));
        }

  参考来源:http://www.cnblogs.com/shenba/archive/2011/04/16/2018441.html

ASP.NET MVC中错误处理方式

标签:csharp   参考   asp   exception   out   处理   ted   asp.net   div   

原文地址:http://www.cnblogs.com/ncellit/p/7686331.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!