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系统架构、维优、项目外包
  • 相关阅读:
    MySQL中遍历查询结果的常用API(c)
    MySQL :LAST_INSERT_ID()函数总结
    安装Mysql时提示尚未安装Python 解决方案
    pthread_cond_broadcast & pthread_cond_signal
    vs 搭配 Linux 开发
    不同宿主的iterator不能进行比较
    error C2338: No Q_OBJECT in the class with the signal (NodeCreator.cpp)
    c++ 中全局/静态存储区的内存污染问题
    TCP与UDP各自优缺点与区别
    简单理解进程与线程
  • 原文地址:https://www.cnblogs.com/tinaleft/p/2909635.html
Copyright © 2011-2022 走看看