zoukankan      html  css  js  c++  java
  • 错误处理程序

    Global.asax代码: 

        void Application_Error(object sender, EventArgs e)  
        {  
            // 在出现未处理的错误时运行的代码 
             
                Exception objErr = Server.GetLastError().GetBaseException(); 
                string error = string.Empty; 
                string errortime = string.Empty; 
                string erroraddr = string.Empty; 
                string errorinfo = string.Empty; 
                string errorsource = string.Empty; 
                string errortrace = string.Empty;

                error += "发生时间:" + System.DateTime.Now.ToString() + "<br>"; 
                errortime = "发生时间:" + System.DateTime.Now.ToString();

                error += "发生异常页: " + Request.Url.ToString() + "<br>"; 
                erroraddr = "发生异常页: " + Request.Url.ToString();

                error += "异常信息: " + objErr.Message + "<br>"; 
                errorinfo = "异常信息: " + objErr.Message;

                //error +="错误源:"+objErr.Source+"<br>"; 
                //error += "堆栈信息:" + objErr.StackTrace + "<br>"; 
                errorsource = "错误源:" + objErr.Source; 
                errortrace = "堆栈信息:" + objErr.StackTrace; 
                error += "--------------------------------------<br>"; 
                Server.ClearError(); 
                Application["error"] = error;

                Common.Log.WriteLog(error);
                Response.Redirect("~/Error/ErrorPage.aspx");      

        }

    ErrorPage.aspx.cs 
     protected void Page_Load(object sender, EventArgs e) 
        { 
            this.Label1.Text = Application["Error"].ToString(); 
        }

    来自杭州西溪。主打Linux系统架构、维优、项目外包
  • 相关阅读:
    JavaScript之HTML DOM Event
    JavaScript 之 Function
    JavaScript 之 "for"的衍生对象
    Javascript object.constructor属性与面向对象编程(oop)
    前端发展简史
    基于MPI的大规模矩阵乘法问题
    Spark-shell错误:Missing Python executable 'python', defaulting to ...
    外文期刊论文的写法精概——“终极八股文大法!!!”
    Java静态方法为什么不能访问非静态方法
    API & Web API
  • 原文地址:https://www.cnblogs.com/tinaleft/p/2909635.html
Copyright © 2011-2022 走看看