按鈕點擊操作代碼如下
{
try
{
throw new Exception(
}
catch (Exception ex)
{
// Log the error to a text file in the Error folder
ErrHandler
}
}
現在
Log Entry :
Error in:http://localhost:
__________________________
Redirecting users on unhandled errors(在未有處理錯誤情況下重定向用戶)
讓我們看看如何在Application級上來捕捉未有錯誤處理而發生的錯誤
要捕捉到未有錯誤處理的錯誤
void Application_Error(object sender
{
// Code that runs when an unhandled error occurs
Exception objErr = Server
string err =
// Log the error
ErrHandler
}
我們注意到通過使用 Server
<!
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request
it enables developers to configure html error pages
to be displayed in place of a error stack trace
<customErrorsmode=
<errorstatusCode=
<errorstatusCode=
</customErrors>
[
From:http://tw.wingwit.com/Article/program/net/201311/15392.html