Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How can I get IIS7 to serve a default image instead of a 404 html page, when an image is requested?

e.g.

request for: http://www.example.com/myImage.jpg

myImage.jpg does not exist, so we deliver another image instead?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Consider URL Rewrite or something like that, although you'll need to do some extending for it to know if the jpg exists or not.

You can use customErrors but that will affect all content type. Additionally, you could add your own HTTPHandler that watches for .jpg files, confirms that they don't exist, and serves up a default image it doesn't exist.

share|improve this answer
    
Ok thanks, that is good advise and I had considered them, but was wondering if it was possible without rolling my own - thanks –  Lucifer Mar 1 '10 at 16:59
    
No, I don't believe so. You can point all .jpg images to a single image, or all 404's to a single image, but there isn't something built-in that allows you throw a custom 404 just for .jpg files. –  Scott Forsyth - MVP Mar 5 '10 at 4:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.