简体   繁体   中英

WebClient login and password to the Website

I'm trying to log in to https://secure.domaintools.com/log-in/?logout (http://whois.domaintools.com)

using (var myWebClient = new WebClient())
{
    string loginData = "username=test@test.com&passowrd=pwd";

    string response = myWebClient.UploadString("https://secure.domaintools.com/log-in/?logout", "POST", loginData);

    myWebClient.Headers["User-Agent"] = "MOZILLA/5.0 (WINDOWS NT 6.1; WOW64) APPLEWEBKIT/537.1 (KHTML, LIKE GECKO) CHROME/21.0.1180.75 SAFARI/537.1";
    myWebClient.DownloadString("http://whois.domaintools.com");
    doc.LoadHtml(page);
}

But have this error

Error 417 Expectation failed

How can I fix that?

将此属性添加到您的代码中

ServicePointManager.Expect100Continue = false;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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