- 3
- 0
- 约3.63千字
- 约 5页
- 2017-09-05 发布于河南
- 举报
net错误处理机制(.net error handling mechanism)
net错误处理机制(.net error handling mechanism)
A provides 4 error mechanism: Page_Error event ErrorPage attribute Application_Error event customErrors configuration
The Page_Error event
The Page_Error event provides a capture at the page level error method. You can only display the error message (as shown in the example code below), you can also record the events or perform some other operation.
Private void Page_Load (object sender, System.EventArgs E)
User code to {/ / Put initialize the page here
Throw new Exception (Page Error!);
}
Protected void Page_Error (object sender, EventArgs E)
{
Exception = Server.GetLastError (objErr) (.GetBaseException);
Response.Write (Error: + objErr.Message);
(Server.ClearError); / / also should pay attention to the use of this code
}
Note: this example shows the detailed error information in the browser, provides this sample only to explain. To the end user application displays detailed information must be careful. A more appropriate approach is to display a message to inform the user, has the error occurred, and then the specific error details recorded in the log.
The ErrorPage property
You can set the ErrorPage attribute in the page at any time, so as to determine the error occurred when the page will redirect to any page. Let the ErrorPage attribute can play a role in the customErrors configuration in the mode property must be set to On.
This.ErrorPage = ~/ErrorHandling/PageError.html;
If Page_Error and ErrorPage are present, when thrown Exception, page execution order is? The page will first execute Page_Error event handling function, if the Page_Error () function call Server.ClearError () in the event of abnormal information, do not jump to the specified ErrorPage property page; if you do not call Server.ClearError (Exception), the information will continue to throw up, the page will jump to the specified ErrorPage page. This proves the priority order: Page_Error event ErrorPage attribute.
.
The Application_Error event
Similar to
您可能关注的文档
- led技术指标(Led technical index).doc
- kx驱动几个基本插件简介(KX drive several basic plug-in profiles).doc
- led显示屏单元板pcb设计规则(LED display panel PCB design rules).doc
- led灯带灯条产品知识。(LED lights, strip products knowledge.).doc
- led灯电源的达标对策(Countermeasures of LED lamp power supply).doc
- led发光原理及特点(Principle and characteristics of LED luminescence).doc
- led电子屏控制原理(LED electronic screen control principle).doc
- led的基本知识(Basic knowledge of LED).doc
- led车铝和压铸铝(LED aluminum and die cast aluminum).doc
- led术语(Led terminology).doc
最近下载
- 高校教师资格证面试说课课件-醛酮.pptx VIP
- 防范电信与网络诈骗犯罪.pptx VIP
- 《中医妇科学》习题.docx VIP
- 统编版高中历史选择性必修2《经济与社会生活》全册教案教学设计(精编含活动课单元测试卷等).docx VIP
- 公交公司员工的劳务合同5篇.docx
- (一模)内蒙古2026年高三第一次模拟考试地理试卷(含答案解析).docx
- 2025年江苏城市职业学院单招考试语文试题含答案解析.docx
- 2025年送电线路工(高级)职业技能鉴定参考试题库(含答案).docx
- 上海市水闸维修养护技术规程—课件.ppt VIP
- 2025年江苏城市职业学院单招笔试英语试题库含答案解析(5卷).docx VIP
原创力文档

文档评论(0)