我创建了一个虚拟目录,对机器B上的每个人都具有读写权限。我在机器A上运行Web应用程序1.现在要求是从此Web应用程序将文件上载到远程http位置。计算机Web应用程序i配置了匿名身份验证。
我无法成功实施上述要求。请说明这种方法是否正确?
public override bool UploadFile()
{
byte[] postData;
try
{
postData = this.FileData;
using (WebClient client = new WebClient())
{
client.Credentials = CredentialCache.DefaultCredentials;
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
client.UploadData(this.UrlString, "PUT", postData);
}
return true;
}
catch (Exception ex)
{
throw new Exception("Failed to upload", ex.InnerException);
}
}
i have tried the example given in the below location
http://code.msdn.microsoft.com/CSASPNETRemoteUploadAndDown-a80b7cb5
不幸的是我无法使其发挥作用。我在机器A和A上都使用IIS7。乙 请建议。