HTTPS Post登录请求C#
我正在尝试使用post请求登录到一个扑克网站。但我没有得到正确的回答。我得到了原始登录页面本身的来源 我知道凭据是正确的,因为它们是手动工作的 下面是尝试登录的代码段。根据我的理解,响应源代码应该是成功登录的源代码HTTPS Post登录请求C#,c#,login,http-post,C#,Login,Http Post,我正在尝试使用post请求登录到一个扑克网站。但我没有得到正确的回答。我得到了原始登录页面本身的来源 我知道凭据是正确的,因为它们是手动工作的 下面是尝试登录的代码段。根据我的理解,响应源代码应该是成功登录的源代码 static void Main(string[] args) { string username = "####"; string password = "########"; HttpWebRequest request = (HttpWebRequest
static void Main(string[] args)
{
string username = "####";
string password = "########";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://ftrpoker.com/login.html");
request.Method = "POST";
using (StreamWriter writer = new StreamWriter(request.GetRequestStream(), Encoding.ASCII))
{
writer.Write("USERNAME=" + username + "&PASSWORD=" + password);
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
Console.WriteLine(reader.ReadToEnd());
}
我也有类似的问题。尝试使用连接到ServicePointManager.ServerCertificateValidationCallback的RemoteCertificateValidationCallback 大概是这样的:
private static bool ValidateRemoteCertificate(object sender,X509Certificate certificate,X509Chain chain,SslPolicyErrors policyErrors)
{
return true;
}
解决方案来自:
确保您的请求已发送到正确的服务器端页面。(可能是
login.php
或login.asp
等)您可以使用chrome/firefox开发者工具中的Networking
选项卡遵循您的请求页面正确。但是我会检查Firefox,看看post参数是否正确