我使用的Web API selef主持人:的StatusCode:404,ReasonPhrase: '未找到',版本:1.1,
public class TestController : ApiController
{
[HttpPost]
public void Testp([FromBody]string title)
{
Console.WriteLine("Post");
}
}
這是簡單的控制器 ,這是我的客戶:
client.BaseAddress = new Uri("http://localhost:1010");
const string englishTitle = "TesteDelete";
var post = client.PostAsync("Test/Testp", new
{
title = englishTitle
}, new JsonMediaTypeFormatter());
var result = post.Result;
if (result.IsSuccessStatusCode)
{
}
else
{
string content = result.Content.ReadAsStringAsync().Result;
}
爲什麼我的結果是:
{StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Date: Sun, 21 Apr 2013 12:00:03 GMT
Server: Microsoft-HTTPAPI/2.0
Content-Length: 165
Content-Type: application/json; charset=utf-8
}}
我thnik我ModelBinder的有一些錯誤
我注意到你沒有用「/」結束你的基礎uri, – eaglei22 2017-05-25 22:46:52