I'm working on converting a website that currently is all static HTML pages
to ASP.NET. Since people may have some of the HTML pages bookmarked, I
want to give them a meaningful error message page and point them to the new
pages. In my web.config file, I put the following:
<customErrors mode="On">
<error statusCode="404" redirect="404NotFound.aspx"/>
</customErrors>
This works fine if I try to request a non-existent file that has a ".aspx"
extension, but it doesn't work if the file has a ".html" extension. So in
IIS on the Custom Errors tab under 404, I put:
Message Type: URL
URL: /MyWeb/404NotFound.aspx
This now works for any file that doesn't have a ".aspx" extension. Now
when I try to go to "http://localhost/MyWeb/BadFile.html" it displays the
error page just fine. The problem comes in when I try to go to a page that
doesn't exist in a sub-directory, for example,
"http://localhost/MyWeb/SubDir/BadFile.html". The error message still
displays, but it can't find any of the images and they just display as red
X's. I always use the ~ in my image URL's (for example, <asp:Image
ImageUrl="~/images/logo.gif">) so I would think it should be able to find
it, but it can't.
Any ideas on what I'm doing wrong?
Thanks,
Laurie