[thelist] Trapping unhandled exceptions (Errors) in ASP.NET User Controls

Volkan Özçelik volkan.ozcelik at gmail.com
Wed Jul 23 19:38:25 CDT 2008


Hi Aleem,

Any suggestions on how to trap any unhandled exceptions for widgets and
> display them on the Dashboard within the widget container? I can't enforce
> other developers to write their entire widget code in try/catch blocks,
> hence the BaseWidget.


That's sounds to be the job of global.asax application_error handler.

The general procedure is to trap the exception, log it, and forward it to
and Error page via Server.Transfer for displaying a friendlier message like:

Exception exception = Server.GetLastError();
LogException(exception);
Server.Transfer(ErrorPageLocation, false);
return;

Also there is a custom errors section in your web.config file.

<configuration>
  <appSettings/>
  <connectionStrings/>
  <system.web>
    <compilation debug="true" />

    <!-- Turn on Custom Errors -->
    <customErrors
      mode="RemoteOnly"
      defaultRedirect="HttpErrorPage.aspx">
    </customErrors >

  </system.web>
</configuration>


The following pointers might help

[1] http://support.microsoft.com/kb/306355
[2] http://aspnetresources.com/articles/CustomErrorPages.aspx
[3] http://msdn.microsoft.com/en-us/library/bb397417.aspx

Cheers
-- 
Volkan Ozcelik
+> Senior Web Application Developer, VeriPark
+> linkibol.com - in seek for quality links : http://www.linkibol.com/
+> my blog (in Turkish): http://www.fikribol.com/donkisot/
+> Sardalya JavaScript Library: http://www.sarmal.com/sardalya/



More information about the thelist mailing list