/// <summary>
/// Application的错误响应。
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Application_Error(Object sender, EventArgs e)
{
System.Exception exp = Server.GetLastError();
//保存或者记录异常日志,这里选择输出
Response.Write(exp.Message);
}
/// Application的错误响应。
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Application_Error(Object sender, EventArgs e)
{
System.Exception exp = Server.GetLastError();
//保存或者记录异常日志,这里选择输出
Response.Write(exp.Message);
}
解决方案 »
- UpdatePanel Repeater HyperLink分页 怎么局部刷新???
- 怎么获取DataList里面选中的对象???
- 操作记录
- 求2级联动下拉框代码,不用autopostback的
- 郁闷!问一个可能是很白痴的问题,关于Discuz论坛的
- 数据库中显示NULL 为什么用row["name"]==null判断不出来呢?
- 用jquery怎麼綁定datalist
- dreamweaver 连接数据库
- 招聘基于B/S结构用LOTUS NOTE 开发OA的软件工程师
- 想到一个问题:ASP.NET怎么在客户端加判断框?欢迎讨论
- 〓〓〓请教各位老大们一个菜问题 “关于.net中使用ubb”〓〓〓
- 有谁做过自定义控件的安装程序?
HOW TO: Create Custom Error Reporting Pages in ASP.NET by Using Visual C# .NET
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q306355
<%@ Import Namespace="System.Diagnostics"%>EventLog 类封装日志本身。它提供了检测或创建日志的静态方法,并且可被实例化以从代码写入日志项。下面的示例说明了 Global.asax 的 Application_Error 方法中的此功能。每当应用程序中发生未处理的异常时,包含错误信息和堆栈跟踪的项便写入应用程序日志。
void Application_Error(Object sender, EventArgs e) { String Message = "\n\nURL:\n http://localhost/" + Request.Path
+ "\n\nMESSAGE:\n " + Server.GetLastError().Message
+ "\n\nSTACK TRACE:\n" + Server.GetLastError().StackTrace; // Create event Log if it does not exist String LogName = "Application";
if (!EventLog.SourceExists(LogName)) {
EventLog.CreateEventSource(LogName, LogName);
} // Insert into event log
EventLog Log = new EventLog();
Log.Source = LogName;
Log.WriteEntry(Message, EventLogEntryType.Error);}