【发布时间】:2016-11-21 14:23:02
【问题描述】:
我正在尝试像这样向我的网络 API 发送一个字符串:
public IList<Product> GetProducts(string myString)
{
IList<Product> retVal = null;
using (var client = GetClient())
{
HttpContent httpContent = new StringContent(myString, Encoding.UTF8, "application/json");
// HTTP POST
HttpResponseMessage response = client.PostAsync("api/products", httpContent).Result;
}
return retVal;
}
在我的 ProductsController 中,我的操作方法如下所示:
// POST: api/products/filter
[HttpPost("filter")]
public IList<Product> Filter(string filter)
{
}
由于某种原因,过滤器参数一直为空。任何想法为什么?
【问题讨论】:
标签: c# asp.net json asp.net-web-api asp.net-web-api2