zoukankan      html  css  js  c++  java
  • asp.net 异常处理

    protected void Application_EndRequest(object sender, EventArgs e)
    {
    // 在应用程序关闭时运行的代码

            HandlerError();
        }
    
        private void HandlerError()
        {            
            if (HttpContext.Current != null)
            {
                if (string.IsNullOrEmpty(Request.QueryString["error"]))
                {
                    var server = HttpContext.Current.Server;
                    var statusCode = HttpContext.Current.Response.StatusCode;
    
                    Exception ex = server.GetLastError();
    
                    if (ex != null || statusCode == 404 || statusCode == 500)
                    {
                        server.ClearError();
                        Response.StatusCode = 404;
                        Response.Redirect("//www.baidu.cn/nopage.html");
                        Response.End();
                        if (ex != null)
                            DependencyResolver.Current.GetService<ILog>().Log(ex);
                    }
                }
            }
    
        }
    
        protected void Application_Error(object sender, EventArgs e)
        {
            // 在出现未处理的错误时运行的代码
            HandlerError();
        }
    这就是
  • 相关阅读:
    开发day7
    开发day6
    开发day5
    开发day4
    开发day3
    开发day2
    开发day1
    假期学习2/8
    什么是栈帧
    JDK、JRE和JVM到底是什么
  • 原文地址:https://www.cnblogs.com/zhangrCsharp/p/7867876.html
Copyright © 2011-2022 走看看