Web ApplicationsProgramAfter the release, in order to give the user a friendly interface and user experience, the user will jump to a custom error page when an error occurs, rather than the detailed exception list exposed to the user by Asp.net.
The simple error handling page can be set through web. config.
<Customerrors Mode= "Remoteonly" Defaultredirect= "Genericerrorpage.htm"><Error Statuscode= "403" Redirect= "Noaccess.htm" /><Error Statuscode= "404" Redirect= "Filenotfound.htm" /></Customerrors>
If you want to program the cause of the error, you can use the page_error event. you can use global. I think this method is more convenient to implement with asax. In addition, it seems more comfortable to combine a separate and more friendly page.
Global. asax(If necessary, you can record the error log)
VoidApplication_error (ObjectSender, eventargs e) {exception objerr = server. getlasterror (). getbaseexception ();StringError ="Exception page :"+ Request. url. tostring () +"<Br>"; Error + ="Exception information :"+ Objerr. Message +"<Br>"; Server. clearerror (); application ["Error"] = Error; response. Redirect ("~ /Errorpage. aspx");}
Errorpage. aspx
Protected VoidPage_load (ObjectSender, eventargs e) {errormessagelabel. Text = application ["Error"]. Tostring ();}
When end users use applications, they may not want to know the cause of the error. In this case, we can use the check box to check whether the cause of the error is displayed. You can place the label in a div and use the check box to determine whether to render the div.
We can make some more friendly designs on the errorpage to make people look more comfortable. Pai_^
Permanent address: http://www.cnblogs.com/yoshow/archive/2007/01/18/623404.html