This question have been asked like million times, but I have tried those solutions and still can't find out why this error is coming up:
Access to the path '\server1\Folder1\Folder2\Folder3\file1.dwg' is denied.
Here is the action which returns the error:
public ActionResult Download(string fileName) { fileName = fileName + ".dwg"; string path = Path.Combine(@"\\server1\Folder1\Folder2\Folder3\", fileName); return File(path, "application/octet-stream", fileName); }
I have tried to giving permissions to "Folder3" for multiple usernames, for example "SERVER1\NETWORK SERVICE" - Full Control.
Application is running under Default Web Site. Application is running under DefaultAppPool and DefaultAppPool has identity of "NetworkService".
Following code gives identity "NETWORK SERVICE".
WindowsIdentity identity = HttpContext.Request.LogonUserIdentity;
The application was working fine (same download directory) on my own computer, but after deploying this problem showed up.
Server is running Windows 2008 R2 SP1 and IIS 7.5.
You may see “Access to the path is denied” error if the application is not able access to a path that is trying to read or write. This will show up as 401 Unauthorized error in IIS logs.
In the IIS Manager , select the Application Pool under which your Web Site is running. Click "Advanced Settings". There will be an entry for Identity (it is under the Process Model section). Click it, provide credentials for your account that has permission to access the share.
Right-click the file or folder, and then click Properties. Click the Security tab. Under Group or user names, click your name to see the permissions you have. Click Edit, click your name, select the check boxes for the permissions that you must have, and then click OK.
Try this:
"Access to the path 'xxxxxx' is denied."
As error says you need to assign permissions to folders
IIS_IUSRS
(Full Control)Full Control
in allowNote: if these steps are not working, then try to give same permission to NETWORK
, NETWORK SERVICE
users
For my case, I went to the root folder of my project, right clicked on it and opened the properties window and unchecked the Read-only attribute. After clicking OK, all started working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With