콘솔 API에서 웹 API를 호출하고 있습니다. 나는 응답으로 HttpResponseMessage
을 얻는다. 해당 메시지 내용을 읽을 수 없습니다. 어떻게 콘솔 앱에서 HTTPResponseMessage 콘텐츠를 추출합니까?
var loginResult = await response.Content.ReadAsAsync<loginresult>(new List<MediaTypeFormatter> { new JsonMediaTypeFormatter() });
비주얼 스튜디오 ReadAsAsync
이 존재하지 않는다고 불평도 MediaTypeFormatter
이 존재하지 않는
MVC에만 적용되는 MediaFormatters
을 사용하기 때문에 왜 작동하지 않는지 이해합니다. ReadAsAsync
도 콘솔 앱을 지원하지 않습니다.
콘솔 앱에서 HTTPResponseMessage
콘텐츠를 어떻게 읽습니까?
어떤 방법으로 "가 작동하지 않습니다"? – OldProgrammer
Visual Studio는'ReadAsAsync'가 존재하지 않으며'MediaTypeFormatter'도 존재하지 않는다고 불평합니다. – Venky
프로젝트에 System.Net.Http에 대한 참조가 있습니까? – Mangist