Put content in HttpResponseMessage object?

后端 未结 8 1517
感情败类
感情败类 2020-11-28 03:31

Several months ago, Microsoft decided to change up the HttpResponseMessage class. Before, you could simply pass a data type into the constructor, and then return the message

8条回答
  •  一生所求
    2020-11-28 03:52

    For a string specifically, the quickest way is to use the StringContent constructor

    response.Content = new StringContent("Your response text");
    

    There are a number of additional HttpContent class descendants for other common scenarios.

提交回复
热议问题