Test the two components are the same error [HttpClient and HttpWebRequest]
The original.net normal
HttpWebRequest the req=(HttpWebRequest) WebRequest. Create (strPostUrl);
The req. ServicePoint. Expect100Continue=false;
The req. Host=PostHost;
The req. KeepAlive=true;
The req. Proxy=null;//
The req. Method="POST";
The req. ContentType="application/x - WWW - form - urlencoded; The charset="+ charset.
The Stream streamReq=the req. GetRequestStream ();
StreamReq. Write (bytPost, 0, bytPost. Length);
StreamReq. Flush ();
HttpWebResponse res=(HttpWebResponse) the req. The method GetResponse ();
In HttpClient test code
HttpContent content=new StringContent (strPostData, Encoding UTF8);
Content. The Headers. ContentType=new System.Net.Http.Headers.MediaTypeHeaderValue (" application/x - WWW - form - urlencoded ");
HttpResponseMessage HRM=hc. PostAsync (strPostUrl, content). The Result;
HRM. EnsureSuccessStatusCode ();
The ResponseText=HRM. Content. ReadAsStringAsync (). The Result;
ResponseAbsoluteUri=HRM. RequestMessage. RequestUri. AbsoluteUri;
The same error found the CORE of the test results, the.net FRAMEWORK is normal operation, the
Thank you,
CodePudding user response:
The server sends 302 pass the client code you what things? Unless you send the HTTP message,Post your HTTP debugger for HTTP uplink message content (message header and the message body) to see messages from the two kinds of target environment program message what's different? !
CodePudding user response:
The same code, NET can be performed, the CORE is unable to perform,You mean send content,