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
  • 相关阅读:
    Ubuntu16.04更新记
    「BZOJ2153」设计铁路
    [UVA-11995]I Can Guess the Data Structure!
    [UVA-11100] The Trip
    [UVA-11039]Children's Game
    [BZOJ1008][HNOI2008]越狱
    NOIP2018退役祭
    修马路
    [NOIP2005]过河
    [POJ1958][Strange Tower of Hanoi]
  • 原文地址:https://www.cnblogs.com/whl4835349/p/11606931.html
Copyright © 2011-2022 走看看