Error Trapping in a VB.NET WEB App

  • Thread starter Thread starter Fred Nelson
  • Start date Start date
F

Fred Nelson

I'm devloping a VB.NET web application and I'm having a problem with
trapping errors and logging the cause of them. When an unexpected error
occurs I want to write it to a file - or e-mail it to me. I have set up
everything according to the documentation however when I get to my error
page "errorpage.aspx" I can't determine why I'm there!

In my web.config file I have the line:
<customErrors ... defaultredirect="errorpage.aspx">

In my global.asax file I have:
sub application_error
server.transfer("errorpage.aspx")

This is sending me to errorpage.aspx when an error occurs.
-------
In errorpage.aspx I have the following:

Imports System
imports system.web
imports system.web.ui
imports system.diagnostics
imports system.application exception

page_load

dim currenterror as new exception = server.getlasterror

The problem is that currenterror is always NULL so I can't do anything!

I'm sure I'm only missing one step to obtain the error - I'm following the
MSDN example and that in a book exactly and its not working.

Any help with this would be GREATLY appreciated!

Thanks Fred
 
I have tried those methods and where used they work fine.

My issue is determing the cause of unexpected errors when my web application
sends me to the error handling page as specified in the web.config file. As
you can see from the posting I can't obtain the error that sent me there
since server.getlasterror is always NULL.

There must be some step that is missing.

Thanks,

Fred
 
Back
Top