Home > Net >  C # POST submission data 302 error solving normal CORE302 error] [NET NET 5.0 test environment
C # POST submission data 302 error solving normal CORE302 error] [NET NET 5.0 test environment

Time:11-15

I use the.net 4.8 normal code but for.net CORE 302 error,
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,

reference 1st floor interacting in a professional developer response:
server to send 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? !
  •  Tags:  
  • C#
  • Related