473,394 Members | 1,944 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,394 software developers and data experts.

Problem in Application_Error

Using some example code I've found, I'm trying to do the custom error page
thing.

I have the following in global.asax..

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim oErr As System.Exception = Server.GetLastError()
Session("LastError") = oErr
End Sub

This throws an error and winds up back in Application_Error. When I get the
error using Server.GetLastError().GetBaseException() everything works as it
should, but the examples I've followed use GetBaseError() in the custom
error page code.

Can someone please explain this to me?

Thanks

--
Michael White
Programmer/Analyst
Marion County, OR
Nov 19 '05 #1
4 1449
Michael:
Are you simply asking what the difference between GetBaseException and
GetBaseError is? I don't know what GetBaseError is, it isn't part of the
framework and must be some custom implementatin that the example you saw
used....

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Michael" <xxx.xxx.xxx> wrote in message
news:eW**************@TK2MSFTNGP12.phx.gbl...
Using some example code I've found, I'm trying to do the custom error page
thing.

I have the following in global.asax..

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim oErr As System.Exception = Server.GetLastError()
Session("LastError") = oErr
End Sub

This throws an error and winds up back in Application_Error. When I get the error using Server.GetLastError().GetBaseException() everything works as it should, but the examples I've followed use GetBaseError() in the custom
error page code.

Can someone please explain this to me?

Thanks

--
Michael White
Programmer/Analyst
Marion County, OR

Nov 19 '05 #2
My typo.. there is no GetBaseError, it should be GetBaseException().

The question is why does Session("LastError") =
Server.GetLastError().GetBaseException() work correctly and
Session("LastError") = Server.GetLastError() not work?
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:O%***************@TK2MSFTNGP14.phx.gbl...
Michael:
Are you simply asking what the difference between GetBaseException and
GetBaseError is? I don't know what GetBaseError is, it isn't part of the
framework and must be some custom implementatin that the example you saw
used....

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Michael" <xxx.xxx.xxx> wrote in message
news:eW**************@TK2MSFTNGP12.phx.gbl...
Using some example code I've found, I'm trying to do the custom error page thing.

I have the following in global.asax..

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim oErr As System.Exception = Server.GetLastError()
Session("LastError") = oErr
End Sub

This throws an error and winds up back in Application_Error. When I get

the
error using Server.GetLastError().GetBaseException() everything works as

it
should, but the examples I've followed use GetBaseError() in the custom
error page code.

Can someone please explain this to me?

Thanks

--
Michael White
Programmer/Analyst
Marion County, OR


Nov 19 '05 #3
Michael:
By the time an exception gets to the Application_Error event, it's been
rebundled as an HttpUnhandledException. Server.GetLastError() will always
return an instance of HttpUnhandledException which really isn't what you
want. Server.GetLastError().GetBaseException() returns the actual exception
(the base exception) which initially caused the error.

In other words a level of indirection is created and this is just how you
get back the piece of information you are really after.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Michael" <xxx.xxx.xxx> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
My typo.. there is no GetBaseError, it should be GetBaseException().

The question is why does Session("LastError") =
Server.GetLastError().GetBaseException() work correctly and
Session("LastError") = Server.GetLastError() not work?
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:O%***************@TK2MSFTNGP14.phx.gbl...
Michael:
Are you simply asking what the difference between GetBaseException and
GetBaseError is? I don't know what GetBaseError is, it isn't part of the
framework and must be some custom implementatin that the example you saw
used....

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Michael" <xxx.xxx.xxx> wrote in message
news:eW**************@TK2MSFTNGP12.phx.gbl...
Using some example code I've found, I'm trying to do the custom error page thing.

I have the following in global.asax..

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim oErr As System.Exception = Server.GetLastError()
Session("LastError") = oErr
End Sub

This throws an error and winds up back in Application_Error. When I get the
error using Server.GetLastError().GetBaseException() everything works
as it
should, but the examples I've followed use GetBaseError() in the

custom error page code.

Can someone please explain this to me?

Thanks

--
Michael White
Programmer/Analyst
Marion County, OR



Nov 19 '05 #4
I understand now. Thanks Karl.
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:eE**************@TK2MSFTNGP15.phx.gbl...
Michael:
By the time an exception gets to the Application_Error event, it's been
rebundled as an HttpUnhandledException. Server.GetLastError() will always
return an instance of HttpUnhandledException which really isn't what you
want. Server.GetLastError().GetBaseException() returns the actual exception (the base exception) which initially caused the error.

In other words a level of indirection is created and this is just how you
get back the piece of information you are really after.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Michael" <xxx.xxx.xxx> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
My typo.. there is no GetBaseError, it should be GetBaseException().

The question is why does Session("LastError") =
Server.GetLastError().GetBaseException() work correctly and
Session("LastError") = Server.GetLastError() not work?
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:O%***************@TK2MSFTNGP14.phx.gbl...
Michael:
Are you simply asking what the difference between GetBaseException and
GetBaseError is? I don't know what GetBaseError is, it isn't part of the framework and must be some custom implementatin that the example you saw used....

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Michael" <xxx.xxx.xxx> wrote in message
news:eW**************@TK2MSFTNGP12.phx.gbl...
> Using some example code I've found, I'm trying to do the custom
error
page
> thing.
>
> I have the following in global.asax..
>
> Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
> Dim oErr As System.Exception = Server.GetLastError()
> Session("LastError") = oErr
> End Sub
>
> This throws an error and winds up back in Application_Error. When I
get the
> error using Server.GetLastError().GetBaseException() everything
works as it
> should, but the examples I've followed use GetBaseError() in the custom > error page code.
>
> Can someone please explain this to me?
>
> Thanks
>
> --
> Michael White
> Programmer/Analyst
> Marion County, OR
>
>



Nov 19 '05 #5

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

Similar topics

1
by: Greg Burns | last post by:
I am trying to write a global custom error page. I thought I would jot down some of what I've learned so far... At first I just used the default customErrors section with a defaultRedirect tag,...
21
by: Gary | last post by:
When using an ASPX page for a DefaultRedirect it does not work if the ASPX page has any code in it. If I put ... If Not IsPostBack Then lblMessage.Text = Server.GetLastError.Message End If ...
0
by: Michael | last post by:
Hi, I have an ASP.NET application that catches un-handled exceptions in the Application_Error method and writes the details to the Event Log. But, if I do a Server.ClearError() followed by either...
0
by: Michael | last post by:
Hi, I have an ASP.NET application that catches un-handled exceptions in the Application_Error method and writes the details to the Event Log. But, if I do a Server.ClearError() followed by either...
2
by: Carl Johansen | last post by:
I've been reading the O'Reilly "ASP.NET Cookbook" 1st edition (Kittel and LeBlond), and it makes a recommendation about exception handling that seems a bit strange. They say that, if you want to...
6
by: Matt | last post by:
Can anyone give me a good reason to use BOTH application scope Page_Error and the page scope Page_Error when trapping errors in a web application? Is there any real benefit to using the Page_Error...
2
by: Matt | last post by:
As the subject says... are Application_Error and Page_Error triggered by the same event? In other words, is there any error that could slip by Application_Error but be caught by Page_Error, or...
1
by: David Herbst | last post by:
VS 2005 / .NET 2.0 Windows 2000 Server sp4 (on development as well as testing server) Using Web Deployment Project to build assemblies for testing and production servers. I added a Global.asax...
1
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
I have a web app that handles errors in the Gloabal.ascx's Application_Error(). It does some logging etc in there and if it throws an error, I want the app to display a static html splash page...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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
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...

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.