[thelist] Trapping unhandled exceptions (Errors) in ASP.NET User Controls
Aleem B
aleemb at gmail.com
Wed Jul 23 23:22:11 CDT 2008
Volkan,
I am trying to localize the error as much as possible. The way my design is
right now, I can capture the error through the Dashboard.aspx itself using
Page.Error event which will capture all unhandled exceptions at the Page
level. However, I want to be able to catch it at the widget level.
If there were some kind of function I could override in UserControl that
does the processing (like the internal ProcessRequestMain) then I could
override it and put that a try/catch block around it so the runtime error
would be trapped while the UserControl is being processed.
Still hoping there's an elegant solution to this problem.
- AleemB
"It is not the mountain we conquer but ourselves" -- Sir Edmund Hillary
(1919 - 2008)
On Thu, Jul 24, 2008 at 5:38 AM, Volkan Özçelik <volkan.ozcelik at gmail.com>
wrote:
> 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/
> --
>
> * * Please support the community that supports you. * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>
More information about the thelist
mailing list