응답은 모든 송신 요청에 대해 작동하지만 responce의 읽는데 동안 나는 오류오류 : InvalidOperationException이 HttpResponseMessage 나는 HttpResponsemessage 과정에 문제가있어
의InvalidOperationException : The character set provided in ContentType is invalid.
using (var handler = new HttpClientHandler())
{
if (handler.SupportsAutomaticDecompression)
{
handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
}
using (var client = new HttpClient(handler) { BaseAddress = new Uri(BaseAddress) })
{
Dictionary<string, string> dico = new Dictionary<string, string>();
dico.Add("username", _username);
dico.Add("password", _password);
HttpResponseMessage response = client.PostAsync("/auth", new FormUrlEncodedContent(dico)).Result;
var tokResult = response.Content.ReadAsStringAsync().Result;
var tokObj = JsonConvert.DeserializeObject<AuthResult>(tokResult);
string token = tokObj.Token;
return token;
}
}
헤더 값을 가지고 응답 :
{StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:{ Connection: keep-alive Server: cloudflare-nginx Transfer-Encoding: chunked CF-RAY: 35e6bfcc8f3c3c77-CDG T411-node: webus1 Set-Cookie: __cfduid=db2de200ea64f72bef261054785e1047c1494690372; expires=Sun, 13-May-18 15:46:12 GMT; path=/; domain=.t411.al; HttpOnly Date: Sat, 13 May 2017 15:46:12 GMT X-Powered-By: PHP/5.5.38-4+deb.sury.org~xenial+1 Content-Type: text/html; charset=windows-1252}}
문제점을 조사 했습니까? 그게 너 한테 뭐라고 했니? 그 문제를 해결하기 위해 당신은 무엇을 했습니까? –
검색을했지만 일치하는 항목을 찾지 못했습니다. 다른 라이브러리와 시도했지만 성공하지 못했습니다. –
나는 보통 wireshark 또는 fiddler와 같은 스니퍼를 사용합니다. IE 브라우저를 사용하고 http 헤더를 캡처하십시오. 그런 다음 헤더를 HttpClient 헤더와 비교하십시오. 그런 다음 httpclient에 누락 된 헤더를 설정하십시오. – jdweng