zoukankan      html  css  js  c++  java
  • 路径问题 Global文件中写入错误日志记录

    “~”表示Web 应用程序根目录,“/”也是表示根目录,“../”表示当前目录的上一级目录,“./”表示当前目录

    1  throw抛出异常     2 执行OnActionExecuted 方法   3执行 Global  中的 Application_Error 方法写入日志

    global文件中写入  错误日志记录

      protected  void Application_Error(object sender,EventArgs e)
            {
                Exception lastError = Server.GetLastError();
                if(lastError!=null)
                {
                    string strExceptionMessage = string.Empty;
                    //对HTTP 404做额外处理,其他错误全部当成500服务器错误
                    HttpException httpError = lastError as HttpException;
                    if(httpError!=null)
                    {
                        //获取错误代码
                        int httpCode = httpError.GetHttpCode();
                        strExceptionMessage = httpError.Message;
                        if(httpCode==400||httpCode==403||httpCode==404)
                        {
                            Response.StatusCode = httpCode;
                            //跳转到指定的静态404信息页面
                            Response.WriteFile("~/404.html");
                            Server.ClearError();
                            return;
                        }
                    }
                    log.Error(lastError.Message, lastError);
                    Response.WriteFile("~/400.html");
    #if DEBUG
    
    #else
                    Server.ClearError();
    #endif
    
    
                }
            }
    111111
  • 相关阅读:
    numpy通用函数
    机器学习之随机森林
    机器学习之支持向量机
    机器学习之逻辑回归
    机器学习之决策树
    机器学*之K*邻
    机器学习之线性回归
    模型之各个指标
    模型之信息熵
    模型之决策树
  • 原文地址:https://www.cnblogs.com/whl4835349/p/11606931.html
Copyright © 2011-2022 走看看