Solved

Custom Error settings only picking up 404 on ASPX

Posted on 2004-08-27
4
220 Views
Last Modified: 2012-06-27
Custom Error settings only picking up 404 on ASPX pages and not directories addresses or other file types such as .html

This is what I have in my web.config.  I'm using a remote host and only have FTP abilities.

     <customErrors mode="RemoteOnly">
       <error statusCode="404" redirect="/error_docs/Oops.aspx" />
     </customErrors>
0
Comment
Question by:dgelinas
4 Comments
 
LVL 17

Accepted Solution

by:
AerosSaga earned 150 total points
ID: 11914404
Since .html files are not being interepreted by the .NET Compiler they would not be redirected on error.  If this is what you want then you would need to put the html pages in a .aspx or .ascx wrapper so that IIS will handle correctly.

Regards,

Aeros
0
 
LVL 15

Assisted Solution

by:Thogek
Thogek earned 150 total points
ID: 11914931
Actually, given that dgelinas is looking for 404 error handling (which occurs when no file exists at the requested URL), there's nothing to wrap in ASPXs....

But Aeros is right: those customErrors settings will only affect errors that arise during (or during an attempt to call) a page/file that is part of the ASP.NET application, which includes any ASPX, ASCX, or related code (C# or VB) files, but does not include HTML files, non-.NET ASP files, etc.

So, if a user attempts to request a URL with a *.aspx extension, the handling of this request would be handed to ASP.NET, and ASP.NET could serve its custom errors.  But if a user attempts to request a URL with a *.html extension, this is not processed by the ASP.NET application, so no customErrors setting in the ASP.NET application would have the chance to come into play.

If you need to specifiy custom 404 error pages for your Web site or application, regardless of whether or not the requested URL is an ASP.NET application file, you'll likely need to do so within IIS itself.  In this case, go into your Internet Information Services Manager, find your Web site or Web application virtual directory, right-click and select "Properties".  Select the "Custom Error" tab, select the line for the HTTP error you wish to intercept (such as 404), then click "Edit Properties".  You can then set the Message Type to File and enter your own local static file to be used, or set the Message Type to URL and specify the URL to which all 404 errors should be redirected.  This will then take effect for all such errors that occur within that Web site or directory, regardless of the type of file being requested.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now