Getting content/message from HttpResponseMessage

后端 未结 8 2171
抹茶落季
抹茶落季 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:07

    I think the following image helps for those needing to come by T as the return type.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题