473,466 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1359
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: KJ | last post by:
Alright, I'm trying to display Ex.Message on a custom error page. Here is what I did. When an error occured I caught the error and saved it in a session variable and when the page redirected...
1
by: bay_dar | last post by:
Hi, According to the information in the web.config file, if I set customErrors mode="RemoteOnly" in the web.config file then: "Display custom (friendly) messages only to users not running on the...
5
by: Peter Lapic | last post by:
I have to create a image web service that when it receives an imageid parameter it will return a gif image from a file that has been stored on the server. The client will be an asp.net web page...
13
by: Jim Carlock | last post by:
I have over a hundred pictures I would like to present. Is it practical to create and parse an array of pictures, picture paths, et al using server-side scripting to accomplish this? I...
3
by: c676228 | last post by:
Hi everyone, I have a piece of code in sales.aspx.vb like this: Protected WithEvents Message As System.Web.UI.WebControls.Label Try ... ChartImage.ImageUrl = "ChartGenerator.aspx?" + DataStr +...
4
by: shapper | last post by:
Hello, I am working in Asp.Net 2.0 web sites and I need to preload some images in my master pages and in the pages that use those master pages. Could someone tell me how to do this? Thanks,...
2
by: Evan M. | last post by:
Hello there, I have an interesting problem to takle. I'm creating a website that's going to be run in a local Intranet. The site uses a MasterPage / content page scheme, with the Master page...
1
by: TrueEmpath | last post by:
I'm trying to create a simple custom control that displays an animation composed of separate image files. However, I'm having trouble with how exactly I use the imported images with the control. When...
18
by: coachjerry | last post by:
I'm a senior citizen with a tech background, though a newbie to programming and style sheets. I'm usually able to make HTML and css changes to existing designs, but I'm stuck on this one and would...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.