I have 3 sites running from 1 DiscountASP.net account. This is the way they have been setup: domain.com/site1/htdocs/ domain.com/site2/htdocs/ domain.com/site3/htdocs/ I need a custom 404 page for each of these sites so in the web.config file for each site, I have added the following in <system.web>: <customErrors mode="On" defaultRedirect="404.aspx" > <error statusCode="404" redirect="404.aspx" /> </customErrors> However, when I go to http://www.domain.com/site1/htdocs/anything the site does not display a custom error page...? I'm certain it must be me doing something ridicoulously easy wrong...??? Any help would be much appreciated
Your web.config looks ok. Instead of navigating to http://www.domain.com/site1/htdocs/anything try http://www.domain.com/site1/htdocs/anything.aspx If this works with the .aspx extension but doesn't work without it, you probably need to add an IIS wildcard application extension to map to aspnet_isapi.dll because without it, requests will never hit the aspnet dll for processing and the default IIS 404 page will be returned. You can also handle this situation by registering an integrated pipeline mode module for II7 in your web.config. More info here: http://learn.iis.net/page.aspx/508/wildcard-script-mapping-and-iis-7-integrated-pipeline/
Thanks CrystalCMS I've managed to get the custom 404 errors to work with .aspx files via the web.config now. I must admit, I'm not overly familiar with IIS (I usually work on a LAMP stack) but I did come up with a solution. All 404 errors are mapped to a file called map.php which looks at the referrer to redirect to the correct 404 for each site. The DASP server I'm using is running IIS 6. Is it faily straightforward to add an IIS wildcard application extension to map to aspnet_isapi.dll? Your solution sounds much better...
It is fairly easy to do on IIS6 if you have access to IIS Manager for your web server. To be honest I don't know if you get the ability to access IIS Manager with IIS6 on DASP because I run with IIS7 myself on here. Wildcard mapping in II6 is described in some detail on the article I linked to in my previous post (http://learn.iis.net/page.aspx/508/wildcard-script-mapping-and-iis-7-integrated-pipeline/), but keep in mind that the article does warn that applying this type of mapping on IIS6 (or IIS7 for that matter) does incur a performance penalty because ALL requests are processed by it, including requests for static files. The alternative to the wildcard mapping method is registering an integrated pipeline mode module in II7 in your web.config - this is preferred because registering managed modules this way does not have such dramatic performance impact as when using wildcard script mappings. Even though the module is invoked for all requests to a web application, all the existing handler mappings are still in effect, which means that the static files are still served by the native IIS static file handler.