Access Denied Errors with HtmlInputFile PostedFile, problem solved.

Why do I get these errors only on 2003 Server IIS 6.0 systems? I have the answer!

I recently added a new server to our system the other day and it was configured with Microsoft Windows 2003 server.  When I put my ASP.Net website onto this new server I started having all sorts of problems with the image upload code.  Specifically, I could not delete a file that was uploaded. I kept getting an "Access to the path is denied" error.

I went through all the standard checks making sure that the ASPNet and IUSR_MACHINENAME accounts had full access to the folder where the images were being upload. Made sure the file didn't have read only permissions. I tested various ways of saving the images via the HtmlInputFile's PostedFile.SaveAs function and using the HTTPFileCollection as well.  I tried deleting with System.IO.File.Delete and FileSystemObject.  Nothing.  That file was stuck there and was refusing to be deleted.

I searched all over the net trying to find the solution to the problem and there were quite a few people out there who have posted similar problems.  Most of the time people were recommending that the ASPNet user have write permissions.  But I had already checked that a dozen times.

Finally I just started giving full control access to all the users listed in the security tab.  Upon giving the Users group full control access I was finally able to delete the files!  YEA!  But what user in this group was the key users.  So I asked a co worker about this and we started comparing user permissions with one of his personal sites where he was uploading users.  Bingo, there it was.  The IIS_WPG user the culprit.

So I changed my permissions around returning them to normal, added the IIS_WPG user to that folder and gave him full control. Alas, all was well in the world again.

I was really surprised how I did not stumble upon this fix while searching the net.  So, now that I spent half a day trying to solve this problem I'm sharing my solution with you and hope it will help save you from many frustrating hours trying to debug this problem. 

9,705 views 6 replies
Reply #2 Top
Thanks for the insight, T-Man.
Reply #3 Top
No problem.  It was just frustrating for me to find the fix so I figured I'd help someone else out. Or try to anyway.
Reply #4 Top
When I have problems with IIS or antying else, and I suspect it has something to do with permissions i start with FILEMON from www.sysinternals.com, do a IISRESET and try the web page. Everything will be made clear in the log from filemon (just make sure you configure the filters before you do a IISRESET, or test your thing, as filemon logs EVERYTING and sometimes a wee bit too much..)

Reply #5 Top
Hi,

Thanks for this tip. I think there is very little on the net because most refer to giving rights to aspnet yada yada yada. I believe one of the iis_wpg members need "full control" access. I suspect the IWAM_xxxxxxxx user (where xxxxxxxx is server name)needs this permission.
Reply #6 Top
Thanks for sharing.
What I find annoying when I try to find solutions for scripting, or computer problems is when I search for the problem, get result, someone else has described the exact same problem, but they all refer to a place where I have to register to see the solution. *tsk* *tsk*