Getting content/message from HttpResponseMessage

后端 未结 8 2237
抹茶落季
抹茶落季 2020-12-01 00:18

I\'m trying to get content of HttpResponseMessage. It should be: {\"message\":\"Action \'\' does not exist!\",\"success\":false}, but I don\'t know, how to get

8条回答
  •  我在风中等你
    2020-12-01 01:16

    By the answer of rudivonstaden

    `txtBlock.Text = await response.Content.ReadAsStringAsync();`
    

    but if you don't want to make the method async you can use

    `txtBlock.Text = response.Content.ReadAsStringAsync();
     txtBlock.Text.Wait();`
    

    Wait() it's important, becаuse we are doing async operations and we must wait for the task to complete before going ahead.

提交回复
热议问题