File.OpenRead() accesses file on share within workgroup but not a remote share?

I have an ASP.NET MVC application that attempts to read a file in using a filestream and File.OpenRead(). When the path to the file is a share on the same workgroup, and I give access to NETWORK SERVICE for the share, this works perfectly as desired.

However, when the path to the share is a UNC path to a remote share within the LAN, with read permissions open for "Everyone", the "File.OpenRead()" method throws an exception saying "Could not find a part of the path".

In my test cases I'm debugging locally with the ASP.NET MVC app being given a UNC path to the computer that it's actually running on. It's a share on my C drive, being "Shared" with permissions to "Everyone" for read access.

Is there something in IIS that needs to be configured? If I try to impersonate, in this context, the impersonation doesn't matter because NETWORK SERVICE was the user trying to access the files when it worked for a share in the same workgroup.


IIS handles authentication when accessing remote shares in a distinct way. Please take a look at this article: UNC Authentication in IIS 6.0. Or search for IIS UNC site:microsoft.com


Verify the share permissions to make sure that the permissions are given to NETWORK SERVICE account to be able to access the share. Permissions are needed to the share as well as the actual files/folders.

[]'s

链接地址: http://www.djcxy.com/p/44168.html

上一篇: 将文件从远程RDP复制到本地计算机

下一篇: File.OpenRead()访问工作组中的共享文件,但不访问远程共享?