问题
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.
回答1:
try this:
"Access to the path 'xxxxxx' is denied."
As Error says You need to assign Permissions to Folders
- Right Click Folder
- Go to Security Tab
- Click on Edit
- Click on Add
- Click on Addvance
- Find Now
- Give Permission to
IIS_IUSRS
(Full Control) - Click On OK
- Click On OK
- Click On
Full Control
in allow - Click On OK
- Again Run the Application
Note: If Above things are not working then try to give same permission to
NETWORK
,NETWORK SERVICE
Users
回答2:
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.
回答3:
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).
来源:https://stackoverflow.com/questions/28360275/iis-access-to-the-path-is-denied