简体   繁体   English

拒绝访问路径'C:\\ xxx \\ yyy \\ zzz \\ abcd_20120309.pdf'

[英]Access to the path 'C:\xxx\yyy\zzz\abcd_20120309.pdf' is denied

I have an ASP.Net website and a C# console application (both developed in VS2010). 我有一个ASP.Net网站和一个C#控制台应用程序(均在VS2010中开发)。 Both upload files to our web server (Windows Server 2003/IIS 6.0). 两者都将文件上传到我们的Web服务器(Windows Server 2003 / IIS 6.0)。 Users logging in to the website can then view and download these files. 然后,登录到网站的用户可以查看和下载这些文件。 This works fine in website. 这在网站上工作正常。 But when I try to download files uploaded by the console application, I get the error: 但是,当我尝试下载由控制台应用程序上传的文件时,出现错误:

        UnauthorizedAccessException
        Access to the path 'C:\xxx\yyy\zzz\abcd_20120309.pdf' is denied.

I have already manually provided "Full Control" to NETWORK SERVICE account for that folder. 我已经为该文件夹的“网络服务”帐户手动提供了“完全控制”权限。

Why is Asp.Net code unable to access a folder created by the console application? 为什么Asp.Net代码无法访问控制台应用程序创建的文件夹?

Any idea? 任何想法? Thanks! 谢谢!

You need to provide access to the folder for IIS_IUSRS (or something along this line). 您需要提供对IIS_IUSRS文件夹的访问权限(或类似的方式)。

AKA you need access for IIS. 也需要您访问IIS。

Including access to everyone, doesnt include this user. 包括对所有人的访问,不包括该用户。 So it must be done directly. 因此,必须直接完成。

Network service will not suffice. 网络服务不足。

If IIS_IUSRS doesnt appear in the list, search for it. 如果IIS_IUSRS没有出现在列表中,请搜索它。

Don't know if it matters in this case but one thing I have seen in the past is: 不知道在这种情况下是否重要,但我过去看到的一件事是:

The application first saves the file in a temporary folder and then moves it to the target folder. 该应用程序首先将文件保存在一个临时文件夹中,然后将其移动到目标文件夹中。

Sometimes, don't know the exact rules, the file access right follows the file in the move. 有时,不知道确切的规则,文件访问权限跟随移动中的文件。 ie the file ends up with the access rights for the temporary folder even in target folder. 即,该文件最终具有对临时文件夹的访问权限,即使在目标文件夹中也是如此。

Check the access rights on the file and see if it differs from the target folder. 检查文件的访问权限,并查看它是否与目标文件夹不同。

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

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