469,607 Members | 1,922 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,607 developers. It's quick & easy.

Error Trapping in a VB.NET WEB App

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


Nov 20 '05 #1
2 1400
Have you tried using the "Try", "Catch" and "Finally"
methods?

-----Original Message-----
I'm devloping a VB.NET web application and I'm having a problem withtrapping errors and logging the cause of them. When an unexpected erroroccurs I want to write it to a file - or e-mail it to me. I have set upeverything according to the documentation however when I get to my errorpage "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 theMSDN example and that in a book exactly and its not working.
Any help with this would be GREATLY appreciated!

Thanks Fred


.

Nov 20 '05 #2
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

<an*******@discussions.microsoft.com> wrote in message
news:05****************************@phx.gbl...
Have you tried using the "Try", "Catch" and "Finally"
methods?

-----Original Message-----
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


.

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Robert Wing | last post: by
2 posts views Thread by Steve Richfield | last post: by
13 posts views Thread by Thelma Lubkin | last post: by
3 posts views Thread by Smriti Dev | last post: by
2 posts views Thread by Bill Stock | last post: by
2 posts views Thread by Captain Nemo | last post: by
9 posts views Thread by 47computers | last post: by
reply views Thread by guiromero | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.