Master Pages, Web User Contols and Error Handling OH MY

G

GCeaser

So here is the desired functionality:

When an error occurs anywhere in my application, I want an error
section on the page to display the error information while still
showing the actual page that the user encountered the error on.

Here is what I have tried:

I have an ASP.Net 2.0 web application. It uses a master page
that has information on it as well as a Web User Control for displaying
error information. By default the web user control is not visible In
order to code the least amount, I am attempting to us the Page_Error
event to populate the Web User Control will the error information and
make it visible.

The problem:
As described in a previous posting - the Page_Error event will
not render the page content by default. (this would accomplish still
showing the user the page where the error was encountered). I can of
course attempt to force the rendering in any of several manners but I
generally receive an error message indicating that
RegisterForEventValidation can only be called during Render. Fine - I
get that and I know I can turn it off and some of the risk around
turning it off.

The Question:
What is everyone else doing? I have to imaging there are other
programmers out here that want to do the least amount of coding with
the best results so I am looking from some feedback on how other people
might have accomplished what I am attempting. :)

Any feedback would be appreciated.
 
R

Ramu

When it is an expected error, I catch the exception at an higher level
function and pass the exception to a utility function that displays the
error in Master Page. All my pages are inherited from custom base page
that is inherited from System.Web.UI.Page and my utility function is
placed in custom base page class.

When it is an un expected error, I override OnError in my custom base
page and transfer (Server.Transfer) it to a Error Display ASPX page
that retrieves the error from Server.GetLastError(). Also, The Error
Display page overrides OnError and responses raw HTML page error
message to avoid recursion problem.

Hth,
Ramu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top