By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,078 Members | 1,846 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,078 IT Pros & Developers. It's quick & easy.

.ASPX page hit twice if Custom Error page in IIS

P: n/a
Hey all,

I'm writing a .NET application where I want all HTTP errors such as 404
to redirect back to the home page.

Since .NET only handles HTTP errors if the client is requesting a .NET
resource (.ASPX, whatever), I need to go into IIS -> Custom Errors tab
and set my homepage under each HTTP error I want to handle. This
allows my page to be shown if someone requests an .ASP or .HTM page
that doesn't exist.

Simple enough so far? Well when I do this, and execute the home page
normally, it gets processed *twice*. I'm not even requesting a missing
resource.

For example, my main page is Default.aspx. If in IIS I set
Default.aspx as my 404 error page, and then go to
"http://whatever.com/Default.aspx", the page is executed *twice* on the
server. If I remove the setting in IIS the behavior goes away.

A little more information some people might ask: No, the page does not
perform a Server.Transfer or Request.Redirect. The version of IIS is 6
(Windows 2003 Server). .NET Framework is 1.1. And the page consists
of a number of user controls (not sure why this would matter but
another vauge posting mentioned this).

Thanks in advance, and if anyone had more specific questions let me
know.

john

Nov 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
bjc
Hi jonhyland - You should have a web.config file if you're running a .net
app. Although you don't have to but the web.config file is "run" when your
app is hit / requested. Amongst other stuff you can set an error
file/message application wide via such a file. Search about on web.config on
asp dot sites.

<jo*******@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hey all,

I'm writing a .NET application where I want all HTTP errors such as 404
to redirect back to the home page.

Since .NET only handles HTTP errors if the client is requesting a .NET
resource (.ASPX, whatever), I need to go into IIS -> Custom Errors tab
and set my homepage under each HTTP error I want to handle. This
allows my page to be shown if someone requests an .ASP or .HTM page
that doesn't exist.

Simple enough so far? Well when I do this, and execute the home page
normally, it gets processed *twice*. I'm not even requesting a missing
resource.

For example, my main page is Default.aspx. If in IIS I set
Default.aspx as my 404 error page, and then go to
"http://whatever.com/Default.aspx", the page is executed *twice* on the
server. If I remove the setting in IIS the behavior goes away.

A little more information some people might ask: No, the page does not
perform a Server.Transfer or Request.Redirect. The version of IIS is 6
(Windows 2003 Server). .NET Framework is 1.1. And the page consists
of a number of user controls (not sure why this would matter but
another vauge posting mentioned this).

Thanks in advance, and if anyone had more specific questions let me
know.

john

Nov 19 '05 #2

P: n/a
bjc wrote:
Hi jonhyland - You should have a web.config file if you're running a
.net app. Although you don't have to but the web.config file is "run"
when your app is hit / requested. Amongst other stuff you can set an
error file/message application wide via such a file. Search about on
web.config on asp dot sites.

That is not the solution in this case. As the OP said, a .net error handling
only works if the .net system is called. When somehow a non-.net resource
is requested (.asp, .html, .gif), then asp.net is never called by IIS and
thus is incapable of responding.

As to why that page is executed twice, I don't know. A "solution" might
be not to set that default.aspx as error page, but to reserve a special
page for that (maybe log the error and then redirect to default.aspx)

Hans Kesting
<jo*******@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hey all,

I'm writing a .NET application where I want all HTTP errors such as
404 to redirect back to the home page.

Since .NET only handles HTTP errors if the client is requesting a
.NET resource (.ASPX, whatever), I need to go into IIS -> Custom
Errors tab and set my homepage under each HTTP error I want to
handle. This allows my page to be shown if someone requests an .ASP
or .HTM page that doesn't exist.

Simple enough so far? Well when I do this, and execute the home page
normally, it gets processed *twice*. I'm not even requesting a
missing resource.

For example, my main page is Default.aspx. If in IIS I set
Default.aspx as my 404 error page, and then go to
"http://whatever.com/Default.aspx", the page is executed *twice* on
the server. If I remove the setting in IIS the behavior goes away.

A little more information some people might ask: No, the page does
not perform a Server.Transfer or Request.Redirect. The version of
IIS is 6 (Windows 2003 Server). .NET Framework is 1.1. And the
page consists of a number of user controls (not sure why this would
matter but another vauge posting mentioned this).

Thanks in advance, and if anyone had more specific questions let me
know.

john

Nov 19 '05 #3

P: n/a
Thanks Hans, I had thought of trying something similar. I'd like to
not have to rely on a 'second' redirect from say a standard ASP page
though.. unless thats the only option. I might take this one to MS,
see what they have to say.

Nov 19 '05 #4

P: n/a
Thanks Hans, I had thought of trying something similar. I'd like to
not have to rely on a 'second' redirect from say a standard ASP page
though.. unless thats the only option. I might take this one to MS,
see what they have to say.

Nov 19 '05 #5

P: n/a
How much u want to bet this will post twice. It's been doing it all
week with Google's new "beta" Groups (which I really don't like, BTW).

Anyways, I figured out the cause of the problem.. it was dumb. There
was an embedded 1x1 pixel "blank.gif" file in the page, I'm assuming
for formatting reasons, and that file was missing from the project.

Since IIS was configured to redirect on any 404 (missing resource)
error my page was being hit twice every time. Thought I'd throw this
one out as I bet a lot of people could run into this unknowingly.

Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.