Frustrations with Error Logging

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi

From classic ASP, I had a custom error handling situation that was
quite simple. Errors were all redirected to Error.asp. This page would
check 2 settings, EmailErrorMessage and DisplayErrorMessage. If
EmailErrorMessage was true, it would send an email with the error
details. If DisplayErrorMessage was true, it would display the message
on screen. Also, if an Administrator was logged in, it would display
the message as they could then handle it.

Now in .NET this is proving EXTREMELY frustrating.

Please correct me if my logic here is wrong: In the web.config file, I
can add the lines:
<customErrors mode="On" defaultRedirect="/Error.aspx">
<error statusCode="400" redirect="/Error.aspx?err=400" />
<error statusCode="401" redirect="/Error.aspx?err=401" />
<error statusCode="403" redirect="/Error.aspx?err=403" />
<error statusCode="404" redirect="/Error.aspx?err=404" />
<error statusCode="408" redirect="/Error.aspx?err=408" />
<error statusCode="500" redirect="/Error.aspx?err=500" />
<error statusCode="503" redirect="/Error.aspx?err=503" />
</customErrors>

That looks like an elegant and simple solution. BUT, error.aspx won't
have access to the error object as this is effectively a redirect, and
the error object is lost.

Now I've seen that you can ("should") handle your error in the
Global.asax area and then transfer to a simple HTML page. But this is
just stupid. Firstly, I'm filling up my global.asax with error
handling code. Secondly, I can send the email with the error info from
this point, but when I redirect to the error page, I lose the ability
to display the error message on screen to administrators.

SO, I can try putting this into global.asax:
void Application_Error(object sender, EventArgs e)
{
Server.Transfer("/Error.aspx");
}

BUT, when this gets to my error page, this new error object doesn't
have the info I would like. I get the error with:
Exception objError = Server.GetLastError().GetBaseException();

But this doesn't have the error code, or line number, etc. I would
like to (for example) be able to filter out the 404 errors, as these
can be handled with a simple redirect to the home page, as that
content has moved, and it's not worth showing an error page for it.
But I can't do that now!

I don't get this new logic. For example, it's got a property
objError.Source, which gives a result: "System.Web". Of course &(%@
System.Web created the error - it's a website system!!!!!

Why did they take away the very simple and useful Line Number and
Error Number (error code)???

Anyone got a good idea on what to do?
.



Relevant Pages

  • RE: Frame for Response.Driect or Server.Transfer
    ... if the result of your server side code ... > frames to other pages. ... >> code and then redirect the user somewhere else. ... >> Response.Redirect or Server.Transfer what frame to display the page in or ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: [PHP] Redirect via GET is loosing characters
    ... RURL = Remote URL. ... As the GET method, which the redirect is ... display what you want to display. ... PHP General Mailing List ...
    (php.general)
  • Re: Frustrations with Error Logging
    ... public class WebPageExceptionWrapper ... If DisplayErrorMessage was true, ... have access to the error object as this is effectively a redirect, ... the error object is lost. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: .NET forms authentication role-based redirection?
    ... I would consider using a Login View control. ... means of a redirect (maybe examine the Response object to determine this. ... If the page is NOT a redirect you could display some ... I think a View control would probably work easiest. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Firefox Error Console links
    ... The Error Console will display an error when a javascript object is thrown. ... If this is done with the normal Error object, ...
    (comp.lang.javascript)