我正在尝试使用textreader从本地计算机上的文本文件中检索数据。我有一个上传例程来让读者打开文件。
当我在本地运行应用程序时,它工作得很好。当我将我的应用程序发布到我的服务器上时,我得到了一个无法找到路径的一部分错误。我认为这个错误与权限有关,因为服务器不能从本地文件系统读取,但我不知道正确的方法来纠正这个问题。
我是否要将应用程序设置为模拟用户?我知道我不可能将每个本地用户机器都设置为允许iusr帐户访问它。
谢谢你的任何想法。
更新*我确保网络服务是应用程序池的用户。我还确保networkService可以访问应用程序所在的本地文件夹。我正在运行IIS7,当我测试这个站点时,我得到了一个错误-
The server is configured to use pass-through authentication with a built-in account to access the specified physical path. However, IIS Manager cannot verify whether the built-in account has access. Make sure that the application pool identity has Read access to the physical path. If this server is joined to a domain, and the application pool identity is NetworkService or LocalSystem, verify that <domain>\<computer_name>$ has Read access to the physical path. Then test these settings again我尝试了各种帖子的建议,包括将domain\servername$添加到文件夹以允许访问,但似乎都不起作用。
有什么想法吗?
发布于 2010-04-23 00:28:11
我解决了这个问题,首先将文件保存到服务器,然后访问服务器的本地文件-
savedFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Path.GetFileName(file.FileName));
file.SaveAs(savedFileName);下面的博客帮了我大忙-- http://www.hanselman.com/blog/default.aspx?date=2008-06-28
发布于 2010-04-21 20:51:37
假设这是IIS 6.5或更高版本,则应用程序池用户必须具有必要的权限。默认情况下,这是网络服务,但很可能不是。
https://stackoverflow.com/questions/2682963
复制相似问题