Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# HttpWebRequest身份验证_C#_Webclient - Fatal编程技术网

C# HttpWebRequest身份验证

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()) {

我们在下面提到的类中有http post方法

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,我们需要随请求一起发送。