简体   繁体   English

即使将Expect100Continue设置为false,Webclient UploadData也会返回错误417

[英]Webclient UploadData returns error 417 even after putting expect100Continue to false

Hi guys trying to upload a tweet from my application and when I do a webclient Upload data it returns a WebExecption "The remote server returned an error: (417) Expectation Failed.", after looking around the net I see that people had to put a expect100continue to false to get it to work, after looking back at my code I already had the snippiet in my code. 嗨,大家好,我尝试从我的应用程序上传一条推文,当我执行一个Webclient上传数据时,它返回一个WebExecption“远程服务器返回了一个错误:(417)Expectation Failed。”,环顾了整个网络,我发现人们不得不回顾我的代码后,期望100继续为false才能使其正常工作,我的代码中已经包含摘要。 Does anyone else know why it's not working? 还有其他人知道为什么它不起作用吗?

Here's my code. 这是我的代码。

        public bool PostTweet(string tweet)
    {
        string aUrl = "http://twitter.com/statuses/update.xml";

        client.Credentials = new NetworkCredential(_username, _password);

        System.Net.ServicePointManager.Expect100Continue = false;

        byte[] tweetBytes = System.Text.Encoding.UTF8.GetBytes("status=" + tweet);

        client.UploadData(aUrl,tweetBytes);

        return true;
    }

Hope this helps, and thanks in advance 希望对您有所帮助,并在此先感谢

将Expect100Continue更改为false 后,尝试创建WebClient实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM