473,408 Members | 2,087 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Global.asax not working

I have my error handling set up in Global.asax:

Sub Application_Error(Sender As Object, E as EventArgs)

In this procedure I call a function in a dll that will write out to a
history file.

This works for some errors, but not others. If it doesn't work, it stops
there and the normal MS error page goes to the User.

For example:

I have the following error:

************************************************** *
Compiler Error Message: BC30684: 'DataSet' is a type and cannot be used as
an expression.

Source Error:

Line 65: Dim parameters() As SqlParameter
Line 66:
Line 67: DataSet = myDbObject.RunProcedure("GetScheduleNames", parameters,
"HistoryLog")
Line 68: HistoryLogGrid.DataSource = ds
Line 69: HistoryLogGrid.DataBind()
************************************************** ******

I know why I got the error, but I would have expected my Global error
handler to handle it.

But it doesn't.

The reason it doesn't handle it is because of this code:

if not HttpContext.Current.Session.SessionID is nothing then
parameters(0).value = HttpContext.Current.Session.SessionID
else
parameters(0).value = ""
end if

If I even reference "HttpContext.Current.Session.SessionID", it dies.

I assume that is because this is an error where ASP is checking the page for
errors before actually handling it and there is no SessionID. If it was a
logic error, this works fine and I can access the SessionID in my Global
error routine.

Why can't I here????

Or at least check if it exists.

I need to find out how to handle this or my Global Error routine is not
going to work.

Thanks,

Tom
Jun 8 '06 #1
2 2323
I think you have got it wrong. You are treating all errors the same.
There are compile time errors and errors triggered by exceptions. Your
error with the dataset is a compile time error and will not be handled
by Application_Error. However, if somehow your sql connection blows up
then an exception will be thrown and your Application_Error should
handle it only if the error happens outside of the event handler ( not
too sure about this). But, the point is that not all errors of the
same.

For example, if you had an computational error in your code I'm sure
you won't expect Application_Error to catch that. Same goes here.
tshad wrote:
I have my error handling set up in Global.asax:

Sub Application_Error(Sender As Object, E as EventArgs)

In this procedure I call a function in a dll that will write out to a
history file.

This works for some errors, but not others. If it doesn't work, it stops
there and the normal MS error page goes to the User.

For example:

I have the following error:

************************************************** *
Compiler Error Message: BC30684: 'DataSet' is a type and cannot be used as
an expression.

Source Error:

Line 65: Dim parameters() As SqlParameter
Line 66:
Line 67: DataSet = myDbObject.RunProcedure("GetScheduleNames", parameters,
"HistoryLog")
Line 68: HistoryLogGrid.DataSource = ds
Line 69: HistoryLogGrid.DataBind()
************************************************** ******

I know why I got the error, but I would have expected my Global error
handler to handle it.

But it doesn't.

The reason it doesn't handle it is because of this code:

if not HttpContext.Current.Session.SessionID is nothing then
parameters(0).value = HttpContext.Current.Session.SessionID
else
parameters(0).value = ""
end if

If I even reference "HttpContext.Current.Session.SessionID", it dies.

I assume that is because this is an error where ASP is checking the page for
errors before actually handling it and there is no SessionID. If it was a
logic error, this works fine and I can access the SessionID in my Global
error routine.

Why can't I here????

Or at least check if it exists.

I need to find out how to handle this or my Global Error routine is not
going to work.

Thanks,

Tom


Jun 8 '06 #2
If I take this line out
"tdavisjr" <td******@gmail.com> wrote in message
news:11**********************@c74g2000cwc.googlegr oups.com...
I think you have got it wrong. You are treating all errors the same.
There are compile time errors and errors triggered by exceptions. Your
error with the dataset is a compile time error and will not be handled
by Application_Error. However, if somehow your sql connection blows up
then an exception will be thrown and your Application_Error should
handle it only if the error happens outside of the event handler ( not
too sure about this). But, the point is that not all errors of the
same.

I agree.

But in this case, the Applicant_Error routine did catch the error. It
actually went through the whole process (where it sends me an email), but as
soon as I accessed the "HttpContext.Current.Session.SessionID", it stopped.

I know this because I put some code into the HistoryLog routine wrote to a
text file.

But if I replace the 5 lines of code with:

parameters(0).value = ""

It works fine.

It was the accessing of the SessionID that caused it to stop working.

I thought that if I checked to see if it was "nothing", that would solve the
problem, but it didn't.

Thanks,

Tom
For example, if you had an computational error in your code I'm sure
you won't expect Application_Error to catch that. Same goes here.
tshad wrote:
I have my error handling set up in Global.asax:

Sub Application_Error(Sender As Object, E as EventArgs)

In this procedure I call a function in a dll that will write out to a
history file.

This works for some errors, but not others. If it doesn't work, it stops
there and the normal MS error page goes to the User.

For example:

I have the following error:

************************************************** *
Compiler Error Message: BC30684: 'DataSet' is a type and cannot be used
as
an expression.

Source Error:

Line 65: Dim parameters() As SqlParameter
Line 66:
Line 67: DataSet = myDbObject.RunProcedure("GetScheduleNames",
parameters,
"HistoryLog")
Line 68: HistoryLogGrid.DataSource = ds
Line 69: HistoryLogGrid.DataBind()
************************************************** ******

I know why I got the error, but I would have expected my Global error
handler to handle it.

But it doesn't.

The reason it doesn't handle it is because of this code:

if not HttpContext.Current.Session.SessionID is nothing then
parameters(0).value = HttpContext.Current.Session.SessionID
else
parameters(0).value = ""
end if

If I even reference "HttpContext.Current.Session.SessionID", it dies.

I assume that is because this is an error where ASP is checking the page
for
errors before actually handling it and there is no SessionID. If it was
a
logic error, this works fine and I can access the SessionID in my Global
error routine.

Why can't I here????

Or at least check if it exists.

I need to find out how to handle this or my Global Error routine is not
going to work.

Thanks,

Tom

Jun 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: fd123456 | last post by:
Hi Tom ! Sorry about the messy quoting, Google is playing tricks on me at the moment. > Global.asax is where you normally have the Global Application > and Session variables and code to...
10
by: Ronnie | last post by:
I've created a simple web application using VS2005 Beta 2. Basically, I've added a Web Form and a Global.asax file. In my Global.asax, I create a method like: public static void TestGlobal()...
19
by: furiousmojo | last post by:
This is a strange problem. I have a project where the contents of global.asax application_error are not firing. It is an asp.net 2.0 application using web application projects. I have another...
4
by: Hardy Wang | last post by:
Hi all, In order to solve code-behind of global.asax problem, I removed the code from global.asax, and just leave one line "<%@ Application Language="C#" Inherits="Global"%>" in this file. Then I...
16
by: thefritz_j | last post by:
We just converted our VS2003 1.1 VB web project (which was working fine) to VS2005 2.0 and now I get: Parser Error Message: Could not load type '<Namespace>.'. Source Error: Line 1: <%@...
8
by: Rob T | last post by:
When I was using VS2003, I was able to compile my asp.net project locally on my machine and copy it to the production server and it would run just fine. I've now converted to VS2005. The project...
1
by: twowaystosayiloveyou | last post by:
Hi all, After setting trace for asp.net application. I get trace information for every page, but no trace information for global.asax. Anyone know how to trace the global.asax file? Thanks.
15
by: =?Utf-8?B?UGF0Qg==?= | last post by:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax code file. In 1.1 I could have a code behind file for the global.asax file. This allow for shared variables of the...
4
by: Joe | last post by:
Hello all! I added a Global.asax to my application. I'm using the Application_BeginRequest event. Everything works fine in my development enviorment but when I publish the web site the...
3
by: Peter Larsen [CPH] | last post by:
Hi, I have a problem where the code in Global.asax.cs runs before the unittests (on test of course). In the global file, i load some data from a Oracle table and save it in...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
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
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...
0
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
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
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,...
0
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...

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.