2
我是自承載Web API。任何從我的集成測試中獲得的要求都能正常工作。但是,任何POST請求都會拒絕連接。我似乎無法處理髮生的事情。HTTP POST在OWIN自主Web API中不起作用
錯誤消息
system.Net.HttpRequestException: An error occured while sending the request to the remote server. SocketException: no connection could be made because the target machine actively refused.
代碼
using (WebApp.Start<App_Start.TestConfiguration>("http:/localhost:8216"))
{
var client = new HttpClient();
client.BaseAddress = new System.Uri("http://127.0.0.1:8216");
var response = await client.PostAsync("/api/MyController", new StringContent("something"));
}
控制器
public string Post(string value)
{
return "Hello!";
}
是啊,這讓我通過它的一部分。現在我有一個400錯誤:( – Mateo