简体   繁体   中英

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. 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. I have tried everything, restarted the PC and still no luck. I should also mention that this server is a VPS on godaddy. 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.

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.

Thanks to @Alexei Levenkov. The problem was that someone changed the code, and the code was trying to open a folder as a file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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