473,399 Members | 4,254 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,399 software developers and data experts.

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.aspx) 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.aspx 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 2229
HttpRequest request = Context.Current.Request;
if (string.Compare(request.LocalPath, "/GenericError.aspx", true))
{
Context.Current.Response.Write("An unhandled error occurred");
Context.Current.Response.End();
}
//should be safe to redirect to GenericError.aspx

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Dan Sikorsky" <Da*********@discussions.microsoft.comwrote in message
news:AD**********************************@microsof t.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.aspx) 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.aspx 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.aspx in the HttpModule?

The problem is redirecting to GenericError.aspx 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.LocalPath, "/GenericError.aspx", true))
{
Context.Current.Response.Write("An unhandled error occurred");
Context.Current.Response.End();
}
//should be safe to redirect to GenericError.aspx

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Dan Sikorsky" <Da*********@discussions.microsoft.comwrote in message
news:AD**********************************@microsof t.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.aspx) 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.aspx 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.aspx, 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.LocalPath, "/GenericError.aspx", true))
{
Context.Current.Response.Write("An unhandled error occurred");
Context.Current.Response.End();
}
//should be safe to redirect to GenericError.aspx

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Dan Sikorsky" <Da*********@discussions.microsoft.comwrote in message
news:AD**********************************@microsof t.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.aspx) 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.aspx 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
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...
3
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...
2
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...
3
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...
7
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...
4
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). ...
3
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...
5
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....
33
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...
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: 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
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,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...
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...
0
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...

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.