Solved

Custom Error settings only picking up 404 on ASPX

Posted on 2004-08-27
4
225 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

752 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