Re: Protecting image files

From: Craig Deelsnyder (cdeelsny_at_NO_SPAM_4_MEyahoo.com)
Date: 04/06/04


Date: Tue, 06 Apr 2004 13:28:46 -0500

Ryan Moore wrote:
> I am creating a site that has an "Uploads" directory where users can upload
> image files (let's say .jpgs and .gifs). When a user uploads an image, the
> system creates a directory within this "Uploads" directory to place their
> image in. What I would like to do is protect the ENTIRE uploads directory so
> a user cannot navigate directly to http://mysite/uploads/2/img.jpg without
> logging into the site first (I'm using forms authentication). I'm trying to

You have to add the file extensions (or I should say remap them) to the
aspnet dll in IIS. Right now, what's happening is the request for those
is never making it to the ASP.NET process, cuz IIS is handling them
differently. Hence your forms authentication is never checked.

Go into IIS, I believe under the 'Configuration' button on your virtual
directory, and map all extensions you want to protect to the ASP.NET dll
(see the .aspx extension for the value to copy).

-- 
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET