Skip to main content
 首页 » 编程设计

c#之系统.UnauthorizedAccessException : Access to the path denied error

2024年02月20日14bhlsheji

我正在使用第 3 方服务器,我正在尝试从我用 c# mvc 制作的 Web 表单将图像上传到服务器。它在我的本地主机上运行良好,当我发布它时它给我一个错误

System.UnauthorizedAccessException: Access to the path 'D:\InetPub\vhosts\abc.com\httpdocs\Images\Sections\Developer\ClientLogo\circle-small-empty.18x18.png' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at System.Web.HttpPostedFileWrapper.SaveAs(String filename) at ab.CorporateSite.Controllers.DeveloperController.ImagePath(HttpPostedFileBase imgfile). 

通过 filezilla,我检查了服务器上我想保存图像的特定文件夹(ClientLogo 文件夹)的权限,acc。它拥有全部权利,在我的本地系统上,我也赋予了网络服务和所有人全部权利。

我从昨天开始就在为这个问题苦苦挣扎,但没有任何效果。请建议我该怎么做??

请您参考如下方法:

您需要为 IIS application pool identity 授予对文件夹的权限您的应用程序正在其下运行。

需要权限的虚拟用户通常是 IIS AppPool\AppPoolNameGoesHere。