zoukankan      html  css  js  c++  java
  • 页面异常

    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;419px;
                   height:212px;margin:120px 0 0 330px;}
                   .rightBtnIc{background:url(@Url.Content("~/images//btn_print.png")) no-repeat;
                               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>
  • 相关阅读:
    树链剖分 (模板) 洛谷3384
    ST表 (模板) 洛谷3865
    IOI 2005 River (洛谷 3354)
    IOI 2005 River (洛谷 3354)
    poj1094 Sorting It All Out
    poj1094 Sorting It All Out
    spfa(模板)
    HAOI 2006 受欢迎的牛 (洛谷2341)
    HAOI 2006 受欢迎的牛 (洛谷2341)
    洛谷1850(NOIp2016) 换教室——期望dp
  • 原文地址:https://www.cnblogs.com/8090sns/p/2813099.html
Copyright © 2011-2022 走看看