asp.Netwebapiカスタム出力結果はResponseに似ている.Write()

1033 ワード

asp.Netwebapiカスタム出力結果はResponseに似ている.Write()
 
[HttpGet]
public HttpResponseMessage HelloWorld()
{
string result = “Hello world! Time is: ” + DateTime.Now;
var resp = new HttpResponseMessage(HttpStatusCode.OK);
resp.Content = new StringContent(result, System.Text.Encoding.UTF8, “text/plain”);
return resp;
}

テキストリンク:https://www.wangdongjie.com/asp-net-webapi%e8%87%aa%e5%ae%9a%e4%b9%89%e8%be%93%e5%87%ba%e7%bb%93%e6%9e%9c%e7%b1%bb%e4%bc%bcresponse-write.html
 
転載先:https://www.cnblogs.com/wangdongjie0101/p/11537857.html