views:

263

answers:

1

Hi, Im trying to use the fileupload control. Im using Visual Web Developer Express on my desktop.

My web application is working fine except I cant use the fileUpload control. I get the following error:

ERROR: Access to the path (My_Directory) is denied

I searched and it appears to be a permissions problem. So I attempted to add the user ASPNET and give appropriate permissions to the directory, however, I was unable to add user "ASPNET". User "ASPNET" was not found.

So then I followed the following directions to add user ASPNET via Control Panel > Administration > Computer management. So now I was able to add user ASPNET to the directory and give appropriate permissions but I still got the above error.

http://p2p.wrox.com/net-web-services/5918-creating-aspnet-user.html

Any ideas on why I cant access the directory?

+1  A: 

If you're using Vista/Windows 7/Win2003/Win2008, the user you need is the Network Service account. You can verify by seeing what user your application pool is running under.

Grant the proper permissions to that account (if indeed it's the account that your application pool is running under) and you'll be golden. Note also that with Windows 7 and Win2008, the default account could be the ApplicationPoolIdentity, which you can find out more information about at http://forums.iis.net/t/1156692.aspx. Regardless, you can simply switch the account that your application pool is running under to the Network Service account to verify that that is the issue.

Ted
Im using windows7 and iis 7.5Im relatively new at this. I dont know how to find what User my app pool is running under.This is what I did.I added "Network Service" and it still did not work. Then IIS > Applications pools > Default App pool > Adavanced Settings > Identity > (switched "Application pool Identity" to "NetworkService". That did not work either. Was I taking the right steps?
citrus
Steps:1. Verify what app pool your site is running under by IIS -> right-click applicable site -> Manage Web Site -> Advanced Settings.2. Go to the advanced settings for that app pool in the way you describe.3. Ensure that is using the Network Service account.4. In your NTFS permissions for the directory in question, add the Network Service account, and grant it modify permissions. This will apply to all sub-directories as well.5. Your file upload should now work.
Ted
still no luck. I followed your step. iis > sites > defaulr web site (its the only one listed) > manage web site > advance > (application pool is set to "DefaultAppPool". I did not change.Then iis > Applications pools > DefaultAppPool > Advanced Settings > Identity > (this was set to "application pool identity", But I changed it to "NetworkService".Now I goto my directory in question > Security > Edit > add >advanced > find now > (select Network Service) then I edit Network service so it has full permissions.still no luckI also tried giving every user full permissions, didnt work
citrus
thanks for attempting to help :) as you can imagine its driving me crazy, spent all of yesterday trying to figure it out before posting to stackoverflow
citrus
You gave "Everyone" full permissions on the directory in question and it still didn't work? Where is the directory you're trying to upload to? If it's a system directory, that would cause permissions issues as well. Provide the whole path and that'll show us what could be the problem. This *is* typically a simple issue, so there's something that should be obviously off. And what's the URL for the page containing the asp:FileUpload control?
Ted
Ted, thankyou. Your last comment helped me find my error. I was using FileUpload1.SaveAs(Server.MapPath("../myDirectory"));where it should have been FileUpload1.SaveAs(Server.MapPath("../myDirectory/myImage.jpg"));Unfortunately for me the error made it appear as it was a permissions issue, and at the same time iis 7.5 changed the default from NETWORK SERVICES to ApplicationPoolIdentity which sent me down a wild goose chase.Thanks for your help :)
citrus