简体   繁体   English

拒绝访问虚拟目录文件夹

[英]Access denied to virtual directory folder

In my ASP MVC 5 application, I am able to upload files successfully to a virtual directory, but when I go to download the same file, I consistently get an access denied exception. 在我的ASP MVC 5应用程序中,我能够成功地将文件上传到虚拟目录,但是当我下载相同的文件时,始终会出现拒绝访问的异常。 The folder is located under: 该文件夹位于:

C:\Inetpub\wwwroot\

I have granted the account under which the application pool for the application runs read and write access to all the folders under Inetpub but I still get the same error. 我已授予该帐户用于该应用程序的应用程序池运行对Inetpub下所有文件夹的读写访问权限的帐户,但仍然出现相同的错误。 I have tried everything, restarted the PC and still no luck. 我已经尝试了一切,重新启动了PC,仍然没有运气。 I should also mention that this server is a VPS on godaddy. 我还要提到的是,该服务器是Godaddy上的VPS。 It's very weird that I can upload files to the folder, but when it goes to reading and downloading the file from the same application, I get access denied. 我可以将文件上传到该文件夹​​,这很奇怪,但是当它要从同一应用程序读取和下载文件时,我将被拒绝访问。 Its Windows Server 2012. Windows Server 2012。

Error: 错误:

Description: An unhandled exception occurred during the execution of the current web request. 说明:执行当前Web请求期间发生未处理的异常。 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. 异常详细信息:System.UnauthorizedAccessException:拒绝访问路径“ C:\\ Inetpub \\ wwwroot \\ SupportUploads \\ ProductFiles \\ SRHTestingProdServer”。

ASP.NET is not authorized to access the requested resource. 没有授权ASP.NET访问请求的资源。 Consider granting access rights to the resource to the ASP.NET request identity. 考虑将资源的访问权限授予ASP.NET请求标识。 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. ASP.NET具有一个基本进程标识(在IIS 5上通常为{MACHINE} \\ ASPNET或在IIS 6和IIS 7上为Network Service,在IIS 7.5上通常是配置的应用程序池标识),如果应用程序没有模拟,则使用该标识。 If the application is impersonating via <identity impersonate="true"/> , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. 如果应用程序正在通过<identity impersonate="true"/> ,则该身份将是匿名用户(通常为IUSR_MACHINENAME)或经过身份验证的请求用户。

To grant ASP.NET access to a file, right-click the file in File Explorer, choose "Properties" and select the Security tab. 要授予ASP.NET对文件的访问权限,请在文件资源管理器中右键单击该文件,选择“属性”,然后选择“安全性”选项卡。 Click "Add" to add the appropriate user or group. 单击“添加”以添加适当的用户或组。 Highlight the ASP.NET account, and check the boxes for the desired access. 突出显示ASP.NET帐户,然后选中所需访问权限的框。

Thanks to @Alexei Levenkov. 感谢@Alexei Levenkov。 The problem was that someone changed the code, and the code was trying to open a folder as a file. 问题是有人更改了代码,并且代码试图将文件夹作为文件打开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM