473,487 Members | 2,622 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1552
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
10870
by: Robert Wing | last post by:
I support an MS Access application in which errors are trapped using the On Error statement. Just recently, the users of this system have experienced run-time error number 3021 on a random basis. ...
2
2351
by: Steve Richfield | last post by:
My error handler works GREAT. However, VBA seems to have some bugs/features that are causing it fits. The little snippet that I put at the end of each routine looks like this: Error_Handler: If...
3
6857
by: Nathan Bloomfield | last post by:
Hi there, I am having difficulty with a piece of code which would work wonders for my application if only the error trapping worked properly. Basically, it works as follows: - adds records...
13
4430
by: Thelma Lubkin | last post by:
I use code extensively; I probably overuse it. But I've been using error trapping very sparingly, and now I've been trapped by that. A form that works for me on the system I'm using, apparently...
3
2011
by: Smriti Dev | last post by:
Hi There, I have the following code and when I try to run it, I get a type mismatch error. I would really appreciate your help with this. Thanks kindly, smriti --- Private Sub cmdOK_Click()
2
2159
by: Bill Stock | last post by:
I have a subform which is causing a 3314 (Field can't contain a null value because required is set to True) error. I solved this problem by trapping it in the before update event. But then I...
2
3857
by: Captain Nemo | last post by:
I'm still using Office 2000 myself, but some of my clients have Office 2003. I've recently added a piece of code to create an instance of Word, open a document, fill in the blanks and become...
9
2093
by: 47computers | last post by:
Pretty new to PHP, I recently started learning about error trapping. As of right now, I include the following into a page in my website: -------BEGIN PASTE-------- error_reporting(E_ERROR |...
2
19391
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
2897
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
7106
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7349
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
600
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.