ASP.NET 无权访问所请求的资源。可以在调试模式下访问文件夹,但在 IIS 上部署时不能

ASP.NET is not authorized to access the requested resource. Can access a folder in debug mode but not when I deploy it on IIS

我的 MVC 应用程序 运行 很好(托管在我的本地计算机上)但是在重新启动系统后它无法访问网络文件夹。但是,在调试模式下它 运行 很好,但是当我发布它时它不起作用。

Exception Details: System.UnauthorizedAccessException: Access to the path '\abc\xyz.txt' is denied.

机器 'abc' 网络上的所有人都可以访问。

一个可能的解决方案是该文件夹向网络服务用户帐户授予写入权限,否则它将永远无法工作。还要确保 aspnet 用户也对该文件夹具有写入权限。

检查它 运行 所在的应用程序池标识。确保身份具有访问该文件夹的权限。