configuration> system.web> customErrors mode="On" def_.net有几种错误">
赞
踩
protected void Application_Error(object sender, EventArgs e) {
Exception objErr = Server.GetLastError().GetBaseException();
Response.Write("Error:" + objErr.Message);
Server.ClearError();
}
3,使用ErrorPage属性
<script language="C#" runat="server">
protected void Page_Load(object sender, EventArgs e) {
this.ErrorPage = "ErrorPage.htm";
}
</script>
4,使用Page_Error事件处理方法
protected void Page_Error(object sender, EventArgs e) {
Exception objErr = Server.GetLastError().GetBaseException();
Response.Write("Error:" + objErr.Message);
Server.ClearError(); //同样要注意这句代码的使用
}
根据优先级从高到低排序:Page_Error事件处理方法 > ErrorPage属性 > Application_Error事件处理方法 > <customErrors>配置项。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。