Access to the path denied on Windows 7 (System.UnauthorizedAccessException)

asp.netSecuritywindows 7

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 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

Best Answer

This was caused by an incorrect path. Nothing to do with Windows 7 or granting access to the ASP.NET accounts