–try...catch...finally try{block} catch(FormatException){response.write("格式错误");} catch(OverflowException ){response.write("溢出");} catch(Exception ex){ex.Message.ToString();}
void Page_Error(object sender,EventArgse) { Response.Write(“发生错误:”+Server.GetLastError().ToString()); Server.ClearError(); } –Application_Error 在应用程序配置文件中,为应用程序执行的声明性错误处理 Appliation对象的Error事件 .应用程序中任何页面抛出异常都会调用 .在global.asax中 .形式为: void Application_Error(object sender,EventArgse) { ...}
DEMO2
编写到windows错误日志
把错误发送邮件到管理员
利用配置文件处理错误
.ASP.NET同以前的ASP一样,当服务器上发生了一个运
行时间或编译时间错误时,就会生成一个html 错误页面。
但是与ASP不同,ASP.NET格外关注的是:要确保在默
认状态下,不会因为这个错误的发生而泄露“安全”信息。

