asp.net webapi自定义输出结果类似Response.Write()

asp.net webapi自定义输出结果类似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

 

posted @ 2019-09-17 22:54  SmallDong  阅读(1415)  评论(0编辑  收藏  举报