473,770 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error Handleing at the Application Level Server Error

Howdy,

I found a nice little book called ASP.NET 2.0 Cookbook by Michael A Kittel
and Geoffrey LeBlond. Anyway, they have some instructions on how to setup
application level error handling. Most of my functions have try..catch to
email me about an error, then I want the application level to fire off to
send the user to a custom page AND log it in the app log. When an error
occurs on my page, i get a server error

Server Error in '/newcart' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code. Exception Details:
System.NullRefe renceException: Object reference not set to an instance of an
object.Source Error: Line 4:
Line 5: Protected Sub Page_Error(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles Me.Error
Line 6: Throw Server.GetLastE rror()
Line 7: End Sub
Line 8: Source File: c:\inetpub\wwwr oot\newcart\add tobag.aspx.vb Line:
6 Any ideas?Also, I'm under the impression that if an actual error occurs,
it will not send me to the error page as specified b/c I'm on my development
machine. is that correct?Thanks! !-- David
Lozzidlozzi@(re move)delphi-ts.comwww.delph i-ts.com

Jul 20 '06 #1
4 2179
David,
You shouldn't have to rethrow the sever last error in your page_error
event. As long as you don't call Server.ClearErr or() the Application_Err or
event should still fire and redirection to the error page should occur as
defined in your web.config.

Incidentally, I normally use the Page_Error event to perform page state
clean up and the Application_Err or event in the global.asax for custom error
handling (such as calling an EntLib exception policy - which could you caould
configure to do your emailing and logging functions).

Depending on the deployment I sometimes use a custom HTTPModule for hooking
in to application events. If I want to change how I'm handling an
application error then I cna change and redeploy th HTTPModule dll rather
than playing with the global.asax.

Hope this helps,
Garth

"David Lozzi" wrote:
Howdy,

I found a nice little book called ASP.NET 2.0 Cookbook by Michael A Kittel
and Geoffrey LeBlond. Anyway, they have some instructions on how to setup
application level error handling. Most of my functions have try..catch to
email me about an error, then I want the application level to fire off to
send the user to a custom page AND log it in the app log. When an error
occurs on my page, i get a server error

Server Error in '/newcart' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code. Exception Details:
System.NullRefe renceException: Object reference not set to an instance of an
object.Source Error: Line 4:
Line 5: Protected Sub Page_Error(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles Me.Error
Line 6: Throw Server.GetLastE rror()
Line 7: End Sub
Line 8: Source File: c:\inetpub\wwwr oot\newcart\add tobag.aspx.vb Line:
6 Any ideas?Also, I'm under the impression that if an actual error occurs,
it will not send me to the error page as specified b/c I'm on my development
machine. is that correct?Thanks! !-- David
Lozzidlozzi@(re move)delphi-ts.comwww.delph i-ts.com

Jul 20 '06 #2
The book states to "rethrow the last exception that occured...we do this
step to avoid having the exception information wrapped with an
HttpUnhandledEx ception exception. ASP.NET automatically creates a new
HttpUnhandledEx ception at the page level unless you rethrow the last
exception." sooo.....

--
David Lozzi
dlozzi@(remove) delphi-ts.com
www.delphi-ts.com
"GarthS" <Ga****@discuss ions.microsoft. comwrote in message
news:1B******** *************** ***********@mic rosoft.com...
David,
You shouldn't have to rethrow the sever last error in your page_error
event. As long as you don't call Server.ClearErr or() the
Application_Err or
event should still fire and redirection to the error page should occur as
defined in your web.config.

Incidentally, I normally use the Page_Error event to perform page state
clean up and the Application_Err or event in the global.asax for custom
error
handling (such as calling an EntLib exception policy - which could you
caould
configure to do your emailing and logging functions).

Depending on the deployment I sometimes use a custom HTTPModule for
hooking
in to application events. If I want to change how I'm handling an
application error then I cna change and redeploy th HTTPModule dll rather
than playing with the global.asax.

Hope this helps,
Garth

"David Lozzi" wrote:
>Howdy,

I found a nice little book called ASP.NET 2.0 Cookbook by Michael A
Kittel
and Geoffrey LeBlond. Anyway, they have some instructions on how to setup
application level error handling. Most of my functions have try..catch to
email me about an error, then I want the application level to fire off to
send the user to a custom page AND log it in the app log. When an error
occurs on my page, i get a server error

Server Error in '/newcart' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code. Exception Details:
System.NullRef erenceException : Object reference not set to an instance of
an
object.Sourc e Error: Line 4:
Line 5: Protected Sub Page_Error(ByVa l sender As Object, ByVal e As
System.EventAr gs) Handles Me.Error
Line 6: Throw Server.GetLastE rror()
Line 7: End Sub
Line 8: Source File: c:\inetpub\wwwr oot\newcart\add tobag.aspx.vb
Line:
6 Any ideas?Also, I'm under the impression that if an actual error
occurs,
it will not send me to the error page as specified b/c I'm on my
development
machine. is that correct?Thanks! !-- David
Lozzidlozzi@(re move)delphi-ts.comwww.delph i-ts.com


Jul 20 '06 #3
David,
I ran a quick test and had no problem throwing the Server.GetLastE rror
within the Page_Error, redirection to the error page occured as expected.
I'll ask a question, and I hope I don't offend ;), have you set the mode of
your customErrors section to 'On'?
eg:
<customErrors defaultRedirect ="~/Error.aspx" mode="On">
</customErrors>

If the mode is Off or RemoteOnly on your development machine you'll get the
standard server error.

As an aside, I don't normally mind the exceptions being wrapped in an
HttpUnhandledEx ception. You can get the original exception from the
InnerException property of the unhandled exception in the application_err or
event. I guess a down side (or up side depending on how you look at it) to
this is that HttpUnhandledEx ceptions are logged in the Application log on the
server.

Garth.
"David Lozzi" wrote:
The book states to "rethrow the last exception that occured...we do this
step to avoid having the exception information wrapped with an
HttpUnhandledEx ception exception. ASP.NET automatically creates a new
HttpUnhandledEx ception at the page level unless you rethrow the last
exception." sooo.....

--
David Lozzi
dlozzi@(remove) delphi-ts.com
www.delphi-ts.com
"GarthS" <Ga****@discuss ions.microsoft. comwrote in message
news:1B******** *************** ***********@mic rosoft.com...
David,
You shouldn't have to rethrow the sever last error in your page_error
event. As long as you don't call Server.ClearErr or() the
Application_Err or
event should still fire and redirection to the error page should occur as
defined in your web.config.

Incidentally, I normally use the Page_Error event to perform page state
clean up and the Application_Err or event in the global.asax for custom
error
handling (such as calling an EntLib exception policy - which could you
caould
configure to do your emailing and logging functions).

Depending on the deployment I sometimes use a custom HTTPModule for
hooking
in to application events. If I want to change how I'm handling an
application error then I cna change and redeploy th HTTPModule dll rather
than playing with the global.asax.

Hope this helps,
Garth

"David Lozzi" wrote:
Howdy,

I found a nice little book called ASP.NET 2.0 Cookbook by Michael A
Kittel
and Geoffrey LeBlond. Anyway, they have some instructions on how to setup
application level error handling. Most of my functions have try..catch to
email me about an error, then I want the application level to fire off to
send the user to a custom page AND log it in the app log. When an error
occurs on my page, i get a server error

Server Error in '/newcart' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code. Exception Details:
System.NullRefe renceException: Object reference not set to an instance of
an
object.Source Error: Line 4:
Line 5: Protected Sub Page_Error(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles Me.Error
Line 6: Throw Server.GetLastE rror()
Line 7: End Sub
Line 8: Source File: c:\inetpub\wwwr oot\newcart\add tobag.aspx.vb
Line:
6 Any ideas?Also, I'm under the impression that if an actual error
occurs,
it will not send me to the error page as specified b/c I'm on my
development
machine. is that correct?Thanks! !-- David
Lozzidlozzi@(re move)delphi-ts.comwww.delph i-ts.com



Jul 20 '06 #4
I take great offense to the thickness of my own skull! Thank you, I'll try
that soon.
--
David Lozzi
dlozzi@(remove) delphi-ts.com
www.delphi-ts.com
"GarthS" <Ga****@discuss ions.microsoft. comwrote in message
news:CB******** *************** ***********@mic rosoft.com...
David,
I ran a quick test and had no problem throwing the Server.GetLastE rror
within the Page_Error, redirection to the error page occured as expected.
I'll ask a question, and I hope I don't offend ;), have you set the mode
of
your customErrors section to 'On'?
eg:
<customErrors defaultRedirect ="~/Error.aspx" mode="On">
</customErrors>

If the mode is Off or RemoteOnly on your development machine you'll get
the
standard server error.

As an aside, I don't normally mind the exceptions being wrapped in an
HttpUnhandledEx ception. You can get the original exception from the
InnerException property of the unhandled exception in the
application_err or
event. I guess a down side (or up side depending on how you look at it)
to
this is that HttpUnhandledEx ceptions are logged in the Application log on
the
server.

Garth.
"David Lozzi" wrote:
>The book states to "rethrow the last exception that occured...we do this
step to avoid having the exception information wrapped with an
HttpUnhandledE xception exception. ASP.NET automatically creates a new
HttpUnhandledE xception at the page level unless you rethrow the last
exception." sooo.....

--
David Lozzi
dlozzi@(remove) delphi-ts.com
www.delphi-ts.com
"GarthS" <Ga****@discuss ions.microsoft. comwrote in message
news:1B******* *************** ************@mi crosoft.com...
David,
You shouldn't have to rethrow the sever last error in your page_error
event. As long as you don't call Server.ClearErr or() the
Application_Err or
event should still fire and redirection to the error page should occur
as
defined in your web.config.

Incidentally, I normally use the Page_Error event to perform page state
clean up and the Application_Err or event in the global.asax for custom
error
handling (such as calling an EntLib exception policy - which could you
caould
configure to do your emailing and logging functions).

Depending on the deployment I sometimes use a custom HTTPModule for
hooking
in to application events. If I want to change how I'm handling an
application error then I cna change and redeploy th HTTPModule dll
rather
than playing with the global.asax.

Hope this helps,
Garth

"David Lozzi" wrote:

Howdy,

I found a nice little book called ASP.NET 2.0 Cookbook by Michael A
Kittel
and Geoffrey LeBlond. Anyway, they have some instructions on how to
setup
application level error handling. Most of my functions have try..catch
to
email me about an error, then I want the application level to fire off
to
send the user to a custom page AND log it in the app log. When an
error
occurs on my page, i get a server error

Server Error in '/newcart' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the
current web request. Please review the stack trace for more
information
about the error and where it originated in the code. Exception
Details:
System.NullRef erenceException : Object reference not set to an instance
of
an
object.Sourc e Error: Line 4:
Line 5: Protected Sub Page_Error(ByVa l sender As Object, ByVal e
As
System.EventAr gs) Handles Me.Error
Line 6: Throw Server.GetLastE rror()
Line 7: End Sub
Line 8: Source File: c:\inetpub\wwwr oot\newcart\add tobag.aspx.vb
Line:
6 Any ideas?Also, I'm under the impression that if an actual error
occurs,
it will not send me to the error page as specified b/c I'm on my
development
machine. is that correct?Thanks! !-- David
Lozzidlozzi@(re move)delphi-ts.comwww.delph i-ts.com




Jul 21 '06 #5

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

Similar topics

10
2724
by: Brian Conway | last post by:
I have no idea what is going on. I have a Login screen where someone types in their login information and this populates a datagrid based off of the login. Works great in debug and test through VS, however, when I change to release and put it out on the web it fails giving me the following error message The underlying connection was closed. Could not establish a trust relationship with the remote server.
4
5392
by: tommy | last post by:
hello everbody, i write a little asp-application with forms-authentication. i copy my aspx-files with web.config to my webspace and i get the error above... i tried to set the custom-errors-tag ="off" but nothing happens.... what is my failure????
12
1624
by: Brett Robichaud | last post by:
Is anyone familiar with this error? I have this running just fine on my local machine but when I pushed it out to our development server I get this error. I have no idea what it is saying. Any clues? -Brett- Server Error in '/' Application. ---------------------------------------------------------------------------- ----
3
375
by: Sean | last post by:
HI There, I am having trouble deploying my .aspx pages to a remote server, I have made changes to the config file and it still returns an error. I have also contacted the server administrator to create an application in IIS, what other checks can I make? Sean !-- error mesage
2
2056
by: news.microsoft.com | last post by:
hi, I am new in ASP.NET i make a page using Visual Studio.net compile and successfully run on local system but when i upload it on my internet live server it always gives me the same error if anyone helps me i will be very thankfull: ---------------------------------------------------------------------------- Server Error in '/' Application. ----------------------------------------------------------------------------
0
5909
by: Adam Getchell | last post by:
I'm attempting to write a custom Authentication module using http://www.15seconds.com/Issue/020417.htm I looked at http://support.microsoft.com/default.aspx?scid=kb;EN-US;307996, but it doesn't setup things the way I want (ie, I want to integrate into an existing web application). So I want to deny unauthenticated users access to everything except the default page. I have an error in web.config. When I comment out these lines: ...
6
391
by: chokk | last post by:
All, I am getting the following error when I try to run a form page. Can someone tell me what this is about and show me how to fix it. Thnaks. Server Error in '/' Application -------------------------------------------------------------------------------- Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and...
1
2853
by: Ramanfromoz | last post by:
Hi, Developing a new we application. Everything okay on my local WIN XP PROFESSIONAL, IIS 5.0 running locally. The website is running smoothly. Now, the same code I am copying over to a WINDOWS 2003 SERVER, I created a new website, allocated port number 6000. Created a release version on my local machine and copied the WEB project from my local to http://ACTYD003:6000
0
2266
by: Joergen Bech | last post by:
Fairly new to ASP.NET 1.1. Getting the error below when running application on a web server outside of my control, but only the first time I run it: 1. After a long period of inactivity (or updating the code-behind dll) accessing any aspx page in the application causes the application to run for the first time. Some of the initialization involves reading and writing some text and xml files using simple streamreader and streamwriter...
0
9595
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9432
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10059
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...
1
10008
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9873
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...
1
7420
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
5313
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
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3974
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.