简体   繁体   English

IIS - 访问路径被拒绝

[英]IIS - Access to the path is denied

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.拒绝访问路径 '\server1\Folder1\Folder2\Folder3\file1.dwg'。

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.我试图为多个用户名授予“Folder3”权限,例如“SERVER1\NETWORK SERVICE”-完全控制。

Application is running under Default Web Site.应用程序在默认网站下运行。 Application is running under DefaultAppPool and DefaultAppPool has identity of "NetworkService".应用程序在 DefaultAppPool 下运行,并且 DefaultAppPool 的标识为“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.服务器正在运行 Windows 2008 R2 SP1 和 IIS 7.5。

Try this:尝试这个:

"Access to the path 'xxxxxx' is denied." “访问路径 'xxxxxx' 被拒绝。”

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 Advanced点击高级
  6. Find Now立即查找
  7. Give Permission to IIS_IUSRS (Full Control)授予IIS_IUSRS权限(完全控制)
  8. Click On OK点击确定
  9. Click On OK点击确定
  10. Click On Full Control in allow单击允许中的Full Control
  11. Click On OK点击确定
  12. Again Run the Application再次运行应用程序

Note: if these steps are not working, then try to give same permission to NETWORK , NETWORK SERVICE users注意:如果这些步骤不起作用,请尝试为NETWORKNETWORK SERVICE用户授予相同的权限

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 anonymous authentication is enabled on your server set read permissions for the IUSR account.如果在您的服务器上启用了匿名身份验证,请为 IUSR 帐户设置读取权限。 To allow access for the application pool identities set read permissions for IIS_USERS group.要允许访问应用程序池标识,请为 IIS_USERS 组设置读取权限。 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).对于 UNC 路径,请确保您的共享文件夹具有相关权限(有关详细信息,请参阅https://technet.microsoft.com/en-us/library/cc726004(v=ws.11).aspx )。

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请执行此操作-右键单击文件夹-转到安全性-从编辑授予对 IIS_USERS 的访问权限

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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