TIPS: Error handling in ASP.Net 2.0
2006-04-01 11:06
585 查看
TIPS: Error handling in ASP.Net 2.0
[/b]
[/b]
Posted by: Rickie Lee http://rickie.cnblogs.com
In order to avoiding generating an ugly error message to end users, we can handle it in two ways.
1. Add a custom error page to web site. When an unhandled error occurs, a user-friendly web page will come and ask the users to come back later.
2. Add a Global.asax file into web site, where you can add log this kind of errors.
Follows the following steps to take care:
[/b]
1. Modify Application_Error method in Global.asax file like this:
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
// Log all unhandled errors
}
2. Config web.config file, add a new child of the <system.web> element:
<customErrors mode="RemoteOnly" defaultRedirect="BasePage/Error.aspx" />
3. Add a user-friendly error-handling web page, which appears when an unhanlded error happens.
Add some conent like this:
Your request generated an internal error!
We apologize for the inconvenience! The error has been reported.
Thanks for accessing http://rickie.cnblogs.com web site!
[/b]
[/b]
Posted by: Rickie Lee http://rickie.cnblogs.com
In order to avoiding generating an ugly error message to end users, we can handle it in two ways.
1. Add a custom error page to web site. When an unhandled error occurs, a user-friendly web page will come and ask the users to come back later.
2. Add a Global.asax file into web site, where you can add log this kind of errors.
Follows the following steps to take care:
[/b]
1. Modify Application_Error method in Global.asax file like this:
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
// Log all unhandled errors
}
2. Config web.config file, add a new child of the <system.web> element:
<customErrors mode="RemoteOnly" defaultRedirect="BasePage/Error.aspx" />
3. Add a user-friendly error-handling web page, which appears when an unhanlded error happens.
Add some conent like this:
Your request generated an internal error!
We apologize for the inconvenience! The error has been reported.
Thanks for accessing http://rickie.cnblogs.com web site!
相关文章推荐
- Error Handling in ASP.NET Core
- Error Handling in ASP.NET Core
- Error Handling in ASP.NET(转载)
- Handling HTTP 404 Error in ASP.NET Web API
- Error Handling in ASP.NET Core
- Exception handling with custom error pages in ASP.NET using C#.
- Error Handling in ASP.NET
- Asynchronous Pages in ASP.NET 2.0
- Master Pages In ASP.NET 2.0
- Rewrite the master page form action attribute in asp.net 2.0
- 捆绑语法详解 Simplified and Extended Data Binding Syntax in ASP.NET 2.0
- Working with Data in ASP.NET 2.0 :: Using TemplateFields in the GridView Control
- get assemblyinfo.cs version info in asp.net 2.0
- ASP.NET MVC 2.0 in Vs2010 :使用C# 4.0中使用动态类型来传递ViewData
- Storing Binary Files Directly in the Database Using ASP.NET 2.0
- cross-page posting in ASP.NET 2.0
- [转载]Encrypting Configuration Information in ASP.NET 2.0 Applications
- ASP.Net MVC Entity Framework Error – More than one context type was found in the assembly ‘ProjectNa
- Understanding the Session Object in ASP.NET 2.0
- Display Videos in ASP.NET 2.0