在 Windows 7 上访问路径被拒绝 (System.UnauthorizedAccessException)

发布于 2024-09-08 01:39:39 字数 856 浏览 4 评论 0原文

我在尝试解析 ASP.NET MVC 应用程序中的 XML 文件时遇到此错误(请参阅标题)。我正处于开发的早期阶段,我只是想让它与 Visual Studio 2010 的内置 DEV 服务器一起使用。

我已尝试了以下所有组合,但仍然没有成功:

  • 向我的整个解决方案授予对 NETWORK SERVICE 帐户的完全访问权限
  • 向我的整个解决方案授予对 IUSER、IIS_IUSRS 帐户的完全访问权限
  • 添加 trust level="Full"
  • 添加 identity impersonate="true" 到我的 web.config
  • 授予对整个 C: 驱动器的 NETWORK SERVICE 帐户的完全访问权限
  • 以管理员身份运行 VS
  • 以管理员身份登录
  • 禁用 Windows 7 用户帐户控制 (UAC)
  • 撞墙

我担心这与 Window 7 安全性有关,但我不确定。还有其他人遇到过这种情况吗?

请注意,我的计算机上没有 ASPNET 帐户名。我认为 Windows 7 和最新版本的 ASP.NET 不再使用该帐户。


编辑:我可以使用 Server.MapPath 使用我的应用程序上传文件,这让我想知道这是否是代码问题。然而,当它说“访问路径 MyProject.Web 被拒绝”并且我应该允许 ASP.NET 帐户访问它时,错误非常清楚。


编辑 #2:这是由不正确的错误引起的小路。与 Windows 7 或授予 ASP.NET 帐户访问权限无关

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

缱绻入梦 2024-09-15 01:39:39

这是由于路径不正确造成的。与 Windows 7 或授予对 ASP.NET 帐户的访问权限无关

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

南渊 2024-09-15 01:39:39

您是否尝试过完全关闭 Windows 安全功能?另请尝试以管理员身份运行您的帐户。 (如果您没有收到带有是或否提示的打开某些内容的警告,您就会知道您是否以管理员身份运行)。

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

若水般的淡然安静女子 2024-09-15 01:39:39

“这是由不正确的路径引起的。与 Windows 7 或授予对 ASP.NET 帐户的访问权限无关”

实际上,即使路径正确,由于某些文件夹需要管理员权限,您也可能会收到相同的错误,例如系统驱动器的根目录(如 C:)。

"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:).

暮色兮凉城 2024-09-15 01:39:39

它与 Windows 7 有关。默认情况下,Windows 7 不允许允许您写入根目录(通常是 C:\ 驱动器)。您必须将该文件写入 UserData 或 Application Data 目录。看来 Windows 7 正在尝试划分写入内容的位置(并且是出于充分的理由)。您只需将要保存的文件指向这些区域之一就可以了。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文