将文件写入远程http服务器

时间:2013-09-23 17:37:57

标签: c# asp.net-mvc

我创建了一个虚拟目录,对机器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。乙 请建议。

0 个答案:

没有答案
相关问题