【发布时间】:2017-02-18 14:20:46
【问题描述】:
我正在通过我的 api 从 json 文件中读取值。如何根据 id 过滤记录?
请在下面找到代码。
[HttpGet]
public HttpResponseMessage Get(int id)
{
var productsjson = File.ReadAllText(HostingEnvironment.MapPath(@"~/App_Data/products.json"));
var response = this.Request.CreateResponse(HttpStatusCode.OK);
response.Content = new StringContent(productsjson, Encoding.UTF8, "application/json");
return response;
}
【问题讨论】:
标签: json asp.net-web-api asp.net-web-api2