473,466 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

.ASPX page hit twice if Custom Error page in IIS

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
5 3433
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wilton Yuan | last post by:
Hello, I am new of ASP.NET, I am trying to develop a web application with ASP.NET and Microsoft Visual Studio .net 2002. I create only one simple page with simple C# code behind, it works fine in...
1
by: Lewis | last post by:
Hi, Im having a problem with an aspx page that I'm building (and rather urgently needing to complete!). Situation is this... Im transforming some XML using an XSLT which builds an HTML form...
1
by: Jerry Tovar | last post by:
I am using .Net 2003 on a XPPro running IIS. I am unable to view any of my ASPX webforms in a browser unless I modify the .ASPX file and replace Codebehind="employee.aspx.cs" with...
6
by: Gary | last post by:
I have the following in my web.config.... <customErrors mode="RemoteOnly" defaultRedirect="Applicationerror.aspx"/> but, my error page does not display. Instead a 'Runtime Error' page...
6
by: John Lau | last post by:
Hi, I am looking at the MS KB Article 306355: HOW TO: Create Custom Error Reporting Pages in ASP.NET by Using Visual C# .NET This article describes how to redirect errors to a custom html...
3
by: Mike Malter | last post by:
I have a general error page that I configured in web.config as <customErrors mode="On" defaultRedirect="CRDefaultError.aspx" /> This error page comes up whenever an error occurs outside of any...
7
by: Nilesh | last post by:
I am using background-image attribute in a CSS file and linking the CSS file to aspx page. But strangly, background-image attribute is not working for relative URL. e.g. If I apply following css...
3
by: Greg Collins [Microsoft MVP] | last post by:
I have done a bit of research of Url Rewriting, but as yet have been unsuccessful at getting it to work well, and there are issues around what file types are supported and how much code you want to...
19
by: =?Utf-8?B?anZjb2FjaDIz?= | last post by:
I've got a global.aspx file that works in my dev environment (vs 2005). When i publish the site to a windows 2000 sp4 box running IIS, the global does not seem to fire. Since it's a test server,...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
1
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
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.