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>
  • 相关阅读:
    设计模式 --建造者模式
    HIVE
    Sqoop Mysql导入Hive完整命令参数解析
    Centos7 安装CDH6.3.2 集群
    sqlalchemy 批量插入
    前后端分离
    后台管理模板
    Springboot
    汇编基础
    百万点数据矢量切片实时聚合展示
  • 原文地址:https://www.cnblogs.com/8090sns/p/2813099.html
Copyright © 2011-2022 走看看