开发者

Set content body of httpresponse?

http://msdn.microsoft.com/en-us/library/system.web.httpresponse.aspx

How do I set the content in the body?

 HTTP/1.1 400 Bad Request  
 Content-Type: application/json;cha开发者_开发知识库rset=UTF-8
 Cache-Control: no-store
 Pragma: no-cache

 {
   "message":"response content example"
 }


Use the Output and OutputStream properties, or the Write method.


myHttpResponse.Write("\"{\"message\":\"response content example\"}\"");


In AspNetCore:

await context.Response.WriteJsonAsync("\"{\"message\":\"response content example\"}\"");

Or using a dynamic object:

await context.Response.WriteJsonAsync(new { message = "response content example" });

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜