Access to the path denied on Windows 7 (System.UnauthorizedAccessException)
I'm getting this error (see title) while trying to parse an XML file in my ASP.NET MVC application. I'm in the early stages of development and I'm just trying to get this working with Visual Studio 2010's built-in DEV server.
I have tried every combination of the following and still no luck:
- Granting FULL access to the NETWORK SERVICE account to my entire solution
- Granting FULL access to the IUSER, IIS_IUSRS accounts to my entire solution
- Adding trust level="Full" to my web.config
- Adding identity impersonate="true" to my web.config
- Granting FULL access to the NETWORK SERVICE account to my entire C: drive
- Running VS as administrator
- Logging in as administrator
- Disabling Windows 7 User Account Control (UAC)
- Smashing head against wall
I fear it's something to do with Window 7 security but I'm not sure. Anyone else experiencing开发者_JS百科 this?
Please note that I do not have an ASPNET account name on my computer. I don't think Windows 7 and the latest version of ASP.NET use that account any more.
EDIT: I am able to upload files with my app using Server.MapPath which makes me wonder if this is a code issue. However the error is pretty clear when it says "access to path MyProject.Web is denied" and that I should allow the ASP.NET account access to it.
EDIT #2: This was caused by an incorrect path. Nothing to do with Windows 7 or granting access to the ASP.NET accounts
This was caused by an incorrect path. Nothing to do with Windows 7 or granting access to the ASP.NET accounts
Have you tried turning off windows security altogether? Also try running your account as the administrator. (You'll know if you are running as admin if you don't get the warning to open something with the yes or no prompt).
"This was caused by an incorrect path. Nothing to do with Windows 7 or granting access to the ASP.NET accounts"
Actually, you can get this same error even if it was the right path, due to admin permissions needed for certain folders, like the root of the System Drive (like C:).
It is related to windows 7. Windows 7 by default does not allow you to write to the root directory usually the C:\ drive. You have to write the file to either the UserData or Application Data directory. It appears that Windows 7 is trying to compartmentalize where stuff is being written (and for good cause). You just need to point your file to be saved into one of these areas and you should be alright.
精彩评论