public class KeywordController : ApiController {
[System.Web.Http.HttpPost]
public bool Post(KeywordInfo obj) {
var v = obj.SearchWord;
return true;
}
}
public static async Task<string> PostAsync(string url, object obj) {
using (var content = new StringContent(obj.ToJson())) {
var response = await _client.PostAsync(url, content);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
}
HttpClientHelper.PostAsync("http://localhost:8098/api/keyword", new KeywordInfo { SearchWord = word });
POST方法断点断不到,似乎参数没有接收到。
([frombody]KeywordInfo obj)
试过了,一样收不到。
自己解决了,郁闷,折腾了一天。