Prevent image access...

Hi,

I want to be able to prevent users from viewing images on my webserver (IIS6) using direct URLs e.g. www.mysite.com/img/treehugger.jpg should not be accesible.

Now, I have read about various methods to prevent hot-linking  etc etc.

One of which involves setting wildcard in IIS6 and redirecting every request to ASP.

However, I found that when I do this I cannot then redirect the user to the image after checking (referr check etc) because asp is handling it (loop scenario?).

Anyway, my set up is as follows:

1) I have a few web app directories which use images from my img (image) directory. The image directory is a virtual mapping to a folder on harddisk and it sits in the root along with web apps which need to access the images.

2) IIS version is 6 (upgrade I know, i know!)

I can think of two ways:

Is it possible to set up so that....

Any attempt to access www.mysite.com/img/treehugger.jpg would redirect to another page which checks for cookie, if cookie present then display image otherwise block.

thanks for your help.


KS
LVL 11
Ramesh SrinivasTechnical ConsultantAsked:
Who is Participating?
 
Amandeep Singh BhullarCommented:
You can restrict the same using IHttpHandler,

Check the articles for details
http://www.codeproject.com/KB/web-security/HttpHandlersInAspNet.aspx
http://www.codeproject.com/KB/web-security/imagehandler.aspx

Hope this will help you
0
 
Ramesh SrinivasTechnical ConsultantAuthor Commented:
Ah, never thought of removing the virual directory and reading from filestream. Hopefully this will not create any side-effects.

thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.