//  home   //  advanced search   //  news   //  categories   //  sql build chart   //  downloads   //  statistics
 ASP FAQ 
Home
ASP FAQ Tutorials

   8000XXXX Errors
   Alerts
   ASP.NET 2.0
   Classic ASP 1.0
      COM / ActiveX Components
      Forms
      General Topics
      Date/Time Routines
      Email Scripts & Info
      Files/Directories & FSO
   Databases
   General Concepts
   Search Engine Optimization (SEO)

Contact Us
Site Map

Search

Web
aspfaq.com
tutorials.aspfaq.com
classicasp.aspfaq.com

ASP FAQ Tutorials :: Classic ASP 1.0 :: Files/Directories & FSO :: How do I avoid 'the red x' when an image is missing?


How do I avoid 'the red x' when an image is missing?

The 'red x' is a fairly telltale symptom of (a) a poorly maintained file system, or (b) poorly written HTML code. :-) There is a way to prevent this nasty little red x from showing up. Read Article #2162, which describes how to set up a custom 404 page to capture mistyped URLs and missing files. You can modify the example there to include the following code: 
 
<% 
    qs = Request.ServerVariables("QUERY_STRING") 
    if left(qs,4)="404;" then qs = right(qs,len(qs)-4) 
    if qs <> "" then 
        qsf = lcase(qs) 
        if right(qsf,4)=".gif" or right(qsf,4)=".jpg" or _ 
            right(qsf,5)=".jpeg" or right(qsf,4)=".png" then 
            Server.Transfer("/404.gif") 
            ' use Response.Redirect for IIS 4.0 
        end if 
    end if 
%>
 
Now any bad request for an image file will result in the 404 graphic to be displayed. For example:

Just make sure that you have a file called /404.gif, or else the custom error page will go into an infinite loop.

Related Articles

Can I include a file in both server-side and client-side script?
Can I read / write a user's file without a prompt?
Can I rename a file using FileSystemObject?
Could I get some help working with files using FileSystemObject?
How do I change the modified time of a file?
How do I create / manipulate images from ASP?
How do I dynamically include files?
How do I find the owner, author, and other properties of a file?
How do I get a list of a folder's subfolders?
How do I get the name of the current URL / page?
How do I prevent people from 'leeching' my CSS or JS files?
How do I prevent people from 'leeching' my images?
How do I retrieve a random file from a given folder?
How do I send the correct filename with BinaryWrite?
How do I sort a list of files?
How do I use FileSystemObject to create a file on the client?
Why do I get 'Disk not ready' errors with FileSystemObject?
Why do I get 'Invalid procedure call or argument'?
Why do I get 'Path not found' errors with Scripting.FileSystemObject?
Why do I get 'Permission Denied' errors with FileSystemObject?
Why do I get 800A0034 errors?
Why do I get 800A003E / Input past end of file errors?
Why do I get 800A0BBA errors?
Why do I get 800A0BBC errors?
Why do I get an 'Invalid Path Character' error?
Why do I get permissions errors after upgrading to Windows XP?
Why does FileSystemObject hang all of a sudden?
Why is 'the operation completed successfully' an error message?

 

 


Created: 4/15/2002 | Last Updated: 4/15/2002 | broken links | helpful | not helpful | statistics
© Copyright 2006, UBR, Inc. All Rights Reserved. (319)

 

Copyright 1999-2006, All rights reserved.
Finding content
Finding content.  An error has occured...