【发布时间】:2014-04-10 10:01:02
【问题描述】:
我有一个 FileManagement(FM) 站点和多个 IIS。在每个 IIS 上,我存储了一些文件,所有这些文件都在共享文件夹下。我需要为客户端创建一个API,当客户端传递服务器地址,物理路径时,FM将从指定的IIS下载文件并返回给客户端。
这是一个放在 IIS A 上的路径文件 Menu.txt:
App_Data\Store\Menu.txt。 App_Data 是共享文件夹,名称为:\SERVER-AppData。
当我将参数传递给 API 时,它将是这样的:
服务器地址:IISA的IP地址
路径:\SERVER-AppData\Store\Menu.txt
我使用 WebClient 在 Test API 项目中下载。
// Create a new WebClient instance
WebClient myWebClient = new WebClient();
myWebClient.Credentials = new System.Net.NetworkCredential("username", "password", "domain");
// Concatenate the domain with the Web resource filename.
string myStringWebResource = Path.Combine(serverAddress, path);
string store = @"E:\file.txt";
// Download the Web resource and save it into the current filesystem folder.
byte[] bytes = myWebClient.DownloadData(myStringWebResource);
当我运行它时,它说:用户名或密码错误。但在 Window Explorer 的 Network 中。我使用正确的用户名和密码连接到该服务器。
【问题讨论】:
标签: c# asp.net-mvc asp.net-web-api