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!
Thursday, March 24, 2005 by T-Man | Discussion: Software Development
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.
Reply #3 Friday, March 25, 2005 9:30 PM
Reply #4 Sunday, March 27, 2005 1:03 AM
Reply #5 Thursday, May 5, 2005 12:43 PM
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 Thursday, May 5, 2005 1:55 PM
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*Please login to comment and/or vote for this skin.
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
- Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
- Access to a great community, with a massive database of many, many areas of interest.
- Access to contests & subscription offers like exclusive emails.
- It's simple, and FREE!








Reply #1 Thursday, March 24, 2005 3:25 PM