Connecting Tech Pros Worldwide Forums | Help | Site Map

HttpModule Error Handler Stuck In Loop

Dan Sikorsky
Guest
 
Posts: n/a
#1: Jul 18 '06
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

Karl Seguin [MVP]
Guest
 
Posts: n/a
#2: Jul 18 '06

re: HttpModule Error Handler Stuck In Loop


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" <DanSikorsky@discussions.microsoft.comwrote in message
news:AD6E4459-E944-490D-8A26-A9D14BFA92F1@microsoft.com...
Quote:
>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

Dan Sikorsky
Guest
 
Posts: n/a
#3: Jul 19 '06

re: HttpModule Error Handler Stuck In Loop


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:
Quote:
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" <DanSikorsky@discussions.microsoft.comwrote in message
news:AD6E4459-E944-490D-8A26-A9D14BFA92F1@microsoft.com...
Quote:
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
>
>
>
Dan Sikorsky
Guest
 
Posts: n/a
#4: Jul 19 '06

re: HttpModule Error Handler Stuck In Loop


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:
Quote:
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" <DanSikorsky@discussions.microsoft.comwrote in message
news:AD6E4459-E944-490D-8A26-A9D14BFA92F1@microsoft.com...
Quote:
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
>
>
>
Closed Thread