gpt4 book ai didi

asp.net - Directory.CreateDirectory 在共享主机上抛出 UnauthorizedAccessException 的可能原因

转载 作者:行者123 更新时间:2023-12-04 20:22:50 24 4
gpt4 key购买 nike

我目前正在开发一个 ASP.NET 3.5/IIS7 应用程序,我正在使用该应用程序 WinHost作为临时托管环境。我有一些我认为是权限问题的戏剧,票务过程刚刚达到“你自己”阶段。

这是我想要做的:

var dir = Server.MapPath("~/MyFolder/NewPath");
Directory.CreateDirectory(dir);

这是我得到的回应:

Access to the path 'E:\web\MyAccount\MyFolder\NewPath' is denied.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path 'E:\web\MyAccount\MyFolder\NewPath' is denied.



堆栈跟踪显示 CreateDirectory 行失败。该应用程序在本地运行良好,并且运行应用程序池的身份具有对“MyFolder”路径的写访问权限。在这两种环境中,信任级别都设置为“完全”。

WinHost 的指导是:

By default the asp.net user has full permissions to your site.



进一步研究它,WindowsIndentity.GetCurrent().Name 返回“W02\aspnet_17884”,它似乎是一个帐户特定的身份。我的感觉是这个帐户无权写入应用程序的文件系统,但是当我提示 WinHost 时,我收到了:

The problem you are running into is related to your application configuration.





What I'd recommend doing is registering and then posting your question in the DiscountASP.NET Community Forum



这显然是问题现在出现在 Stack Overflow 上的原因:)

任何人都可以建议任何应用程序级别的配置更改吗?这更可能是托管站点上的权限问题吗?谢谢。

更新:我也 put the question up on the WinHost forum .

最佳答案

答案是......网络部署打破了它。实际上,答案是权限根本不存在(正如预期的那样),但原因似乎是 web 部署以某种方式删除了写入权限。我可以从具有发布 ACL 能力的 Web 部署的角度看到这一点,但是为什么 WinHost 允许它操纵包含网站的目录的权限,这超出了我的理解。

关于我的问题(和 WinHost 的回复)的更多信息,在他们的论坛上的主题 No write access to file system 下。 .

关于asp.net - Directory.CreateDirectory 在共享主机上抛出 UnauthorizedAccessException 的可能原因,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4552918/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com