Error Trapping in VB.NET Web Application

  • 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.

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
 
Back
Top