Web请求不返回任何内容

时间:2015-02-17 16:09:02

标签: c# webrequest

我尝试在此处登录此网站:https://freebitco.in/ 所以我设置了一个像这样的Web请求:

    var request = (HttpWebRequest)WebRequest.Create("https://freebitco.in");
    var postdata = "op=login&btc_address=BTCADDRESS&password=PASSWORD";
    var data = Encoding.ASCII.GetBytes(postdata);

    request.Method = "POST";
    request.ContentType = "application/x-www-form-urlencoded";
    request.ContentLength = data.Length; //1PkhThc9hCXpdvcThtwX3SzbfmTzDFxL1h:bigken <= BTC Login

    using (var stream = request.GetRequestStream())
    {
        stream.Write(data, 0, data.Length);
    }

    var response = (HttpWebResponse)request.GetResponse();
    var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
    MessageBox.Show(responseString);

消息框虽然没有回复,但是空白。我不确定为什么会这样,所以我希望有人可以对此有所了解?我也尝试过使用Web客户端,它给了我相同的结果。感谢你们。

编辑:这是Fiddler Raw数据:http://pastebin.com/WUEvq6D5 编辑2:尝试编码POST数据,现在返回登录页面

更新代码:

    var request = (HttpWebRequest)WebRequest.Create("https://freebitco.in");
    var postdata = "op=login&btc_address=ADDRESS&password=PASS";
    var encoded_data = HttpUtility.UrlEncode(postdata);
    var data = Encoding.ASCII.GetBytes(encoded_data);

    request.Method = "POST";
    request.ContentType = "application/x-www-form-urlencoded";
    request.ContentLength = data.Length;

    using (var stream = request.GetRequestStream())
    {
        stream.Write(data, 0, data.Length);
    }

    var response = (HttpWebResponse)request.GetResponse();
    var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();

0 个答案:

没有答案