473,657 Members | 2,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HttpModule Error Handler Stuck In Loop

I use an HttpModule that handles unhandled exceptions from an .aspx.cs page
by logging to a text file, logging to the event viewer's app log, and sending
out an email to the website developer and any interested parties. Finally, a
user friendly page (GenericError.a spx) is Redirected To.

My Page_Load event has no code, so when the page is unavailable, (for
instance, the website is down), an unhandled event is generated and my
HttpModule is called. Everything is executed as listed above, but the
redirection to GenericError.as px generates another unhandled exception
(because the website is down), and thus we enter into a loop.

I end up with 14000+ email messages, and so does everyone specified in a
web.config list.

The only fix I can see is to put a try/catch block in every Page's Page_Load
event.

Is there some smarter way to handle this?

--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS
Jul 18 '06 #1
3 2238
HttpRequest request = Context.Current .Request;
if (string.Compare (request.LocalP ath, "/GenericError.as px", true))
{
Context.Current .Response.Write ("An unhandled error occurred");
Context.Current .Response.End() ;
}
//should be safe to redirect to GenericError.as px

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Dan Sikorsky" <Da*********@di scussions.micro soft.comwrote in message
news:AD******** *************** ***********@mic rosoft.com...
>I use an HttpModule that handles unhandled exceptions from an .aspx.cs page
by logging to a text file, logging to the event viewer's app log, and
sending
out an email to the website developer and any interested parties. Finally,
a
user friendly page (GenericError.a spx) is Redirected To.

My Page_Load event has no code, so when the page is unavailable, (for
instance, the website is down), an unhandled event is generated and my
HttpModule is called. Everything is executed as listed above, but the
redirection to GenericError.as px generates another unhandled exception
(because the website is down), and thus we enter into a loop.

I end up with 14000+ email messages, and so does everyone specified in a
web.config list.

The only fix I can see is to put a try/catch block in every Page's
Page_Load
event.

Is there some smarter way to handle this?

--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS

Jul 18 '06 #2
Where do I place this code?

Should it go just before the redirect to GenericError.as px in the HttpModule?

The problem is redirecting to GenericError.as px which is in the website that
is down, resulting in firing the HttpModule again.

--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS
"Karl Seguin [MVP]" wrote:
HttpRequest request = Context.Current .Request;
if (string.Compare (request.LocalP ath, "/GenericError.as px", true))
{
Context.Current .Response.Write ("An unhandled error occurred");
Context.Current .Response.End() ;
}
//should be safe to redirect to GenericError.as px

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Dan Sikorsky" <Da*********@di scussions.micro soft.comwrote in message
news:AD******** *************** ***********@mic rosoft.com...
I use an HttpModule that handles unhandled exceptions from an .aspx.cs page
by logging to a text file, logging to the event viewer's app log, and
sending
out an email to the website developer and any interested parties. Finally,
a
user friendly page (GenericError.a spx) is Redirected To.

My Page_Load event has no code, so when the page is unavailable, (for
instance, the website is down), an unhandled event is generated and my
HttpModule is called. Everything is executed as listed above, but the
redirection to GenericError.as px generates another unhandled exception
(because the website is down), and thus we enter into a loop.

I end up with 14000+ email messages, and so does everyone specified in a
web.config list.

The only fix I can see is to put a try/catch block in every Page's
Page_Load
event.

Is there some smarter way to handle this?

--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS


Jul 19 '06 #3
I see it now. The code goes in at the top of the HttpModule to protect
against being called by the GenericError.as px, which was already called by
the HttpModule.
--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS
"Karl Seguin [MVP]" wrote:
HttpRequest request = Context.Current .Request;
if (string.Compare (request.LocalP ath, "/GenericError.as px", true))
{
Context.Current .Response.Write ("An unhandled error occurred");
Context.Current .Response.End() ;
}
//should be safe to redirect to GenericError.as px

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Dan Sikorsky" <Da*********@di scussions.micro soft.comwrote in message
news:AD******** *************** ***********@mic rosoft.com...
I use an HttpModule that handles unhandled exceptions from an .aspx.cs page
by logging to a text file, logging to the event viewer's app log, and
sending
out an email to the website developer and any interested parties. Finally,
a
user friendly page (GenericError.a spx) is Redirected To.

My Page_Load event has no code, so when the page is unavailable, (for
instance, the website is down), an unhandled event is generated and my
HttpModule is called. Everything is executed as listed above, but the
redirection to GenericError.as px generates another unhandled exception
(because the website is down), and thus we enter into a loop.

I end up with 14000+ email messages, and so does everyone specified in a
web.config list.

The only fix I can see is to put a try/catch block in every Page's
Page_Load
event.

Is there some smarter way to handle this?

--
Thank you kindly,

Dan Sikorsky BA, BSCE, MCS


Jul 19 '06 #4

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

Similar topics

3
2204
by: Samuel | last post by:
I wrote a very simple httpmodule and tried to compile it with no success. This is my code: ============== Imports System Imports System.Web Imports Microsoft.VisualBasic NameSpace myErrorHandler
3
3750
by: Michael Iantosca | last post by:
I have a custom attribute that I attach to certain pages in my application and I want to inspect each page request as it is made to see if the custom attribute is attached to the underlying page class. If is attached I want to perform some action. How can I access custom attributes from an HttpModule? I have to pass a target to the System.Attribute.GetCustomAttribute() call to attempt to retrieve the attached attribute. I tried to access...
2
2157
by: Will | last post by:
Hi, I am having trouble with a HttpModule which is registered to handle the HttpApplication.Error event. All works well until I throw an error from within the Session_End or Application_End event handlers in the global.asax.cs file - the HttpModule event handler I attached to the Application.Error does not run under these circumstances! Can anyone explain why? Thanks in advance, Will
3
1230
by: Rob | last post by:
Thank you in advance for your help. I have a response.redirect in my global.asax.vb file to redirect to err.aspx page, upon an error the redirect works fine but in the err.aspx all I simply want to do is write out the error for now and do a bunch of other stuff later, but with the following code, everytime the whole web app freezes up and just sits there and nothing happens!! dim objerr As Exception = Server.GetLastError.GetBaseException ...
7
2573
by: nail | last post by:
Folks, I develop a HttpModule and it works correct, but one problem is occurs. After I register the httpmodule in the web.config, my pages (not testing http://localhost/site but http://my_machine_name/site) show problems when refresh the page. I guess some kind of javascript problems with the postback methods. Someone has any idea how can i fix it? Thanks
4
6193
by: | last post by:
I have earlier used an HttpModule that did URL rewrites on the BeginRequest event. Now I am trying to use the same module in a different application on a new and upgraded machine (winxp sp2). The Module is registered via Web.config. The registration is OK. When asking for an existing .aspx page, the eventhandler is called as it should. HOWEVER - if the request url is for a non-existant file, I get a 404 - file
3
2124
by: MWells | last post by:
I'm having an issue getting my HttpHandlers and HttpModules to play together nicely. My HttpHandlers take special document types (defined by extension) and process them specially. I might have an HttpHandler installed to render Excel files as HTML, or to render TIFFs to JPEGs, etc. The HttpModules are used for Uri handling, so that a request for a resource like;
5
1409
by: Raj | last post by:
Hi there, I have written a small httpmodule which basically scan the incoming request on a perticular domain and pass the url based on mappings. more like a url rewriter e.g. http://www.abc.com/joe.block/index.html will actully be mapped to c:\root\docs\somedir\joeblocks\index.html for this HttpModule to take effect I have done the wildcard mapping on main folder but I want to allow to have classic asp pages in one of
33
3142
by: Anthony England | last post by:
I am considering general error handling routines and have written a sample function to look up an ID in a table. The function returns True if it can find the ID and create a recordset based on that ID, otherwise it returns false. **I am not looking for comments on the usefulness of this function - it is only to demonstrate error handling** There are three versions of this code. David Fenton says under the earlier thread "DAO...
0
8425
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
8743
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...
0
8622
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...
0
7355
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
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
4173
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
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2745
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
2
1736
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.