拒绝访问虚拟目录文件夹

Access denied to virtual directory folder

在我的 ASP MVC 5 应用程序中,我能够成功地将文件上传到虚拟目录,但是当我去下载相同的文件时,我总是遇到拒绝访问异常。该文件夹位于:

C:\Inetpub\wwwroot\

我已授予应用程序的应用程序池运行的帐户对 Inetpub 下的所有文件夹的读写权限,但我仍然遇到相同的错误。我已经尝试了一切,重新启动了 PC,但仍然没有运气。我还应该提到这个服务器是 godaddy 上的 VPS。我可以将文件上传到文件夹,这很奇怪,但是当它从同一个应用程序读取和下载文件时,我被拒绝访问。它的 Windows 服务器 2012。

Error:

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 'C:\Inetpub\wwwroot\SupportUploads\ProductFiles\SRHTestingProdServer' is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in File Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

感谢@Alexei Levenkov。问题是有人更改了代码,代码试图将文件夹作为文件打开。