473,796 Members | 2,618 Online
Bytes | Software Development & Data Engineering Community
+ 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.asp x">

In my global.asax file I have:
sub application_err or
server.transfer ("errorpage.asp x")

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.diagnost ics
imports system.applicat ion exception

page_load

dim currenterror as new exception = server.getlaste rror

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 1568
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.asp x">

In my global.asax file I have:
sub application_err or
server.transfer ("errorpage.asp x")

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.diagnost ics
imports system.applicat ion exception

page_load

dim currenterror as new exception = server.getlaste rror

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.getlaste rror is always NULL.

There must be some step that is missing.

Thanks,

Fred

<an*******@disc ussions.microso ft.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.asp x">

In my global.asax file I have:
sub application_err or
server.transfer ("errorpage.asp x")

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.diagnost ics
imports system.applicat ion exception

page_load

dim currenterror as new exception = server.getlaste rror

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
10888
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. My biggest problem right now is that the error description associated with this error is Application-defined or object-defined error. It has always been my understanding that these error numbers would not be used by Microsoft and were available...
2
2384
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 Error_Handler("<routine name>", Err) = acDataErrDisplay Then On Error GoTo 0 Stop: Resume ' Press twice to view the problem.
3
6902
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 from rsSource into rsDest - if it finds a key violation then it deletes the current record from rsDest and adds the new record from rsSource. This works perfectly - but only for the first found duplicate record, it brings up the error
13
4487
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 runs into problems on the system where it will actually be used, and since I used so little error-trapping it dies very ungracefully. I will of course try to fix whatever is causing the error and add error-trapping to the functions where the...
3
2043
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
2184
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 started getting a "No Current Record" error. I wanted to see what err number was coming through, so I put a MsgBox in the subform's error event. But the MsgBox never came up and the error is now gone. Is the MsgBox pulling the focus away from the...
2
3880
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 visible so the document can be printed and/or modified. This all takes place within one form, in which the Word.Application and Word.Document objects are both private form-level variables. Just to be on the safe side I included this piece of code in...
9
2110
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 | E_PARSE); set_error_handler("SendErrorReport"); function SendErrorReport($errorNumber, $errorMessage, $errorFile, $errorLine, $vars) {
2
19496
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
10459
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10237
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10018
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7553
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6795
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.