IIS - Access to the path is denied

烂漫一生 提交于 2019-11-28 02:48:49

问题


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

  1. Right Click Folder
  2. Go to Security Tab
  3. Click on Edit
  4. Click on Add
  5. Click on Addvance
  6. Find Now
  7. Give Permission to IIS_IUSRS (Full Control)
  8. Click On OK
  9. Click On OK
  10. Click On Full Control in allow
  11. Click On OK
  12. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!