473,372 Members | 1,016 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,372 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 2321
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.