Reputation: 423
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.
Upvotes: 29
Views: 75387
Reputation: 224
In my case we are using IIS with accounts through domain controller. At development stage with Visual Studio (.netCore 6) during debugging i had no problem accessing, creating and modifying files in network. After i had published and host the project on IIS (version 10) the "Access Denied" error appeared.
I tried all the following methods
I have solved it by changing the application pool identity to the same credentials that i am using with domain controller. How To.
click the ... icon
5.On the new pop up window, check "Custom Account"
6.Hit OK
Now everything should work fine.
P.S. I guess that can work in an other direction, by trying to add the already Application Pool Identity in the permissions of the folder (I have not tried it).
Upvotes: 1
Reputation: 22
Please give the full control permission to your directory. Please do this -Right click on folder -Go to security -From Edit give access to IIS_USERS
Upvotes: -1
Reputation: 10275
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
Upvotes: 64
Reputation: 4527
If anonymous authentication is enabled on your server set read permissions for the IUSR account. To allow access for the application pool identities set read permissions for IIS_USERS group. For UNC-path sure that there are relevant permission for your shared folder (see https://technet.microsoft.com/en-us/library/cc726004(v=ws.11).aspx for details).
Upvotes: 2
Reputation: 1781
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.
Upvotes: 7