472,096 Members | 2,215 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,096 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 2229
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

22 posts views Thread by fd123456 | last post: by
19 posts views Thread by furiousmojo | last post: by
8 posts views Thread by Rob T | last post: by
1 post views Thread by twowaystosayiloveyou | last post: by
15 posts views Thread by =?Utf-8?B?UGF0Qg==?= | last post: by
4 posts views Thread by Joe | last post: by
3 posts views Thread by Peter Larsen [CPH] | last post: by

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.