471,123 Members | 869 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,123 software developers and data experts.

Display images in Custom Error Pages

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

Nov 19 '05 #1
1 1279
Another observation I've made is that the URL in the browser doesn't update.
When I go to http://localhost/MyWeb/SubDir/BadFile.aspx, the URL in the
browser updates to
http://localhost/MyWeb/404NotFound.a...r/BadFile.aspx.
However if I go to http://localhost/MyWeb/SubDir/BadFile.html, the URL in
the address bar is never updated even though the contents of the error page
are displayed (with the images messed up). If I look at the source of the
HTML, the form tag look like:

<form name="form1" method="post"
action="404NotFound.aspx?404;http://localhost/MyWeb/SubDir/BadFile.html"
id="form1">

That makes me think the form needs to be posted or something.

I must be missing something very basic here. Any help would be appreciated.

Thanks,
Laurie

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Peter Lapic | last post: by
3 posts views Thread by c676228 | last post: by
2 posts views Thread by Evan M. | last post: by

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.