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:
拒绝访问路径'\ server1 \ Folder1 \ Folder2 \ Folder3 \ file1.dwg'.
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);
}
我尝试为多个用户名(例如"SERVER1 \ NETWORK SERVICE"-完全控制)授予"Folder3"权限.
I have tried to giving permissions to "Folder3" for multiple usernames, for example "SERVER1\NETWORK SERVICE" - Full Control.
应用程序正在默认网站"下运行.应用程序在DefaultAppPool下运行,并且DefaultAppPool的标识为"NetworkService".
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.
服务器正在运行Windows 2008 R2 SP1和IIS 7.5.
Server is running Windows 2008 R2 SP1 and IIS 7.5.
推荐答案
尝试一下:
访问路径'xxxxxx'被拒绝."
"Access to the path 'xxxxxx' is denied."
如错误所述,您需要为文件夹分配权限
As Error says You need to assign Permissions to Folders
- 右键单击文件夹
- 转到安全性"标签
- 单击编辑"
- 点击添加
- 点击高级
- 立即查找
- 授予
IIS_IUSRS
(完全控制)权限 - 单击确定"
- 单击确定"
- 单击允许中的
Full Control
- 单击确定"
- 再次运行应用程序
- 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
注意::如果上述操作均无效,请尝试授予相同的权限
NETWORK
,NETWORK SERVICE
用户
Note: If Above things are not working then try to give same permission to
NETWORK
,NETWORK SERVICE
Users
这篇关于IIS-拒绝访问路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!