WebApi中直接返回json字符串的方法

[HttpPost]
public HttpResponseMessage Upload()
{
	string json = "{\"result\":\"true\"}";
	return new HttpResponseMessage { Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json") };
}



//生成web api帮助文档help  参数1数据  参数2类型 参数3控制器名 参数4Action名
//\Areas\HelpPage\App_Start\HelpPageConfig.cs   Register方法中新增对应的sample
config.SetSampleResponse(AliExpress.Sample.CateSample.CateGetData(), new MediaTypeHeaderValue("application/json"), "Cate", "Get");



posted @ 2016-10-10 17:48  深南大道  阅读(382)  评论(0编辑  收藏  举报