华赐软件 Bootstrap3

页面异常

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>

 

posted @ 2012-12-11 16:08  OpenCsharp.Net  阅读(189)  评论(0编辑  收藏  举报
华赐软件 Bootstrap3
w.huacisoft.com">华赐软件 Bootstrap3