【发布时间】:2015-10-20 05:18:28
【问题描述】:
我的项目是全新的 Asp.net 2015 MVC6 beta 8 web 应用程序。
当我从 C# 代码调用具有帖子类型的 Web api 时,我得到的值为 null。
我的服务器端代码:
// POST api/values
[HttpPost]
public void Post([FromBody]string value)
{
if( null != value )
do something;
}
我的客户端是:
StringContent cstrJson = new StringContent("{ mesage: hello}"
, System.Text.Encoding.Unicode, "application/x-www-form-urlencoded");
var result = await client1.PostAsync("http://localhost:68888/api/myApi/", cstrJson);
我尝试了所有不同的编码和媒体组合,但没有任何改进。
【问题讨论】:
标签: asp.net-mvc asp.net-web-api http-post visual-studio-2015