页面异常
Action:
View Code
protected override void OnException(ExceptionContext filterContext) { if (filterContext == null) return; var ex = filterContext.Exception ?? new Exception(" not futher infomation exists ."); filterContext.ExceptionHandled = true; var controllerName = filterContext.RouteData.Values["controller"] as string; var actionName = filterContext.RouteData.Values["action"] as string; var errorTitle = string.Format("程序类名称:{0},页面名称:{1},发生了异常 ", controllerName, actionName); var contentError = errorTitle + " 异常原因 :" + ex.Message; LogHelper.Error("程序后台出现了异常", errorTitle, filterContext.Exception); ViewBag.ErrorMessage = HttpUtility.HtmlEncode(contentError); ViewBag.TheException = ex; ViewBag.ShowMessage = !(filterContext.Exception == null); ViewBag.ShowLink = false; filterContext.Result = View("Error", ViewBag); }
Page:
View Code
@{ Layout = null; } <!DOCTYPE html> <html> <head> <title></title> <style type="text/css"> .wrapPowerError{background:#ededed;} .powerErrorTips { background:#ededed url(@Url.Content("~/images/powerIcon.png")) no-repeat;width:419px; height:212px;margin:120px 0 0 330px;} .rightBtnIc{background:url(@Url.Content("~/images//btn_print.png")) no-repeat; width:78px;height:25px; margin-top:45px;text-align:center; cursor:pointer; display:inline-block; font-size:12px; font-weight:bold; line-height:25px; } </style> </head> <body class="wrapPowerError"> <div class="powerErrorTips"> <div style="padding: 19px 0 0 21px; font-size: 12px; font-weight: bold;"> 系统提示</div> @if (ViewBag.ShowMessage) { <div style="color: #b1040b; font-weight: bold; font-size: 14px; padding: 50px 72px 0 72px;"> <h3> 500 applaction Error! </h3> <p> @ViewBag.ErrorMessage</p> </div> } else { <div style="color: #b1040b; font-weight: bold; font-size: 14px; padding: 50px 72px 0 72px;"> <h3> 404 Page not found! </h3> <p> Page not Fund! </p> </div> } <div style="text-align: center;"> <a onclick="javascript:history.back()" class="rightBtnIc">返回</a></div> </div> </body> </html>
阿里云: www.aliyun.com
华赐软件: www.huacisoft.com
C#开源社区: www.opencsharp.net
清泓美肤苑: 清泓美肤苑
bootstrap权限管理系统: Asp.Net Mvc3 bootstrap权限管理系统