473,756 Members | 2,977 Online
Bytes | Software Development & Data Engineering Community
+ 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.Redirec t. 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 3449
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*******@hotm ail.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.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.Redirec t. 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*******@hotm ail.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.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.Redirec t. 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
4209
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 the developing computer. After I move all files to another computer on which web server is istting, then I add one link to the home page of my original ASP web application, Click the link, it shows a run time error: Server Error in '/'...
1
5826
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 using an aspx (C# - using VS.NET). Within the resulting HTML is a form, which contains the following : <form method="POST" action="recieveForm.aspx?lang=eng">
1
2813
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 src="employee.aspx.cs". It looks like my bin/employee.dll file is not being used. Instead, my employee.aspx.cs file is being used.
6
4138
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 displays showing how to setup CustomErrors. However, if I make my error page a .htm page it shows fine. Anyone know why?
6
3563
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 error page. All six steps in the article work just fine. Then at the end of the article, there is a little comment about redirecting errors to an aspx page (instead of an html page):
3
3229
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 try/catch blocks. This page has a text box in it that I would like to fill with relevant information about the error. I am trying to put the Server.GetLastError().ToString() in there. It did not work on the page, and I read somewhere that I should...
7
5129
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 ..navbar-background { background-image: url(images/menubar.gif); } the image is not appearing on the page. It seems that IE is picking
3
4743
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 write. While working on a similar, though partially unrelated, issue, I came across a possible alternate method. Before I pursue this method in full, I wanted to get opinions of others as to any unforseen issues I might encounter. The method is...
19
5135
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, i've tried granting the user that IIS is using with all kinds of rights, that didn't work.... so is there some setting i'm missing somewhere. Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when an unhandled...
0
9456
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
9873
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
9713
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
8713
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...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
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
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
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.