C# HttpWebRequest身份验证
我们在下面提到的类中有http post方法C# HttpWebRequest身份验证,c#,webclient,C#,Webclient,我们在下面提到的类中有http post方法 public static class Http { public static byte[] Post(string uri, NameValueCollection pairs) { byte[] response = null; using (WebClient client = new WebClient()) {
public static class Http
{
public static byte[] Post(string uri, NameValueCollection pairs)
{
byte[] response = null;
using (WebClient client = new WebClient())
{
response = client.UploadValues(uri, pairs);
}
return response;
}
}
我们正在尝试登录,但无法登录,
请参阅下面提到的post方法及其参数
var response = Http.Post("https://test.com/login.shtml", new NameValueCollection() {
{ "accountname", "XXXX" },
{ "username", "XXXX" },
{ "password", "XXXX" },
});
您知道接收端如何处理数据吗?通过post传递身份验证参数是不常见的,它们通常在身份验证标头中传递。参见Hi Lukos中的示例,我在fiddler中比较了请求,唯一的区别是它只有一个附加参数,即它为每个请求自动生成的formHash,我们需要随请求一起发送。