ENV: C# .NET FrameWork 4.6.1
App: ASP.NET MVC
Server Code:
public HttpResponseMessage GetQrCode()
{
var jsonStr = "{\"IsSuccess\":true,\"Data\":\"somedate\"}";
var response = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(jsonStr, Encoding.UTF8, "text/json")
};
return response;
}
Client Code:
HttpClient httpClient = new HttpClient();
var response = await httpClient.PostAsync("http://localhost:18188/home/GetQrCode", null);
var statusCode = response.StatusCode;
string result = await response.Content.ReadAsStringAsync();
result Value:
StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
{
Content-Type: text/json; charset=utf-8
}
How do I get the values in the response content?
Why did it turn out that way? What's wrong? Thanks