![](/img/trans.png)
[英]Ninject WebAPI.SelfHost Performance Issues under load (for a few seconds every few more seconds)
[英]c# WebApi.SelfHost post is null
我正在使用WebApi.SelfHost,但我的帖子始終為null。 我嘗試了在SO上可以找到的所有解決方案,但沒有一個起作用。
我被這個問題困擾了幾個小時。 我嘗試了所有可以在SO上找到的解決方案,但沒有一個起作用。
我知道這個問題已經問過了。 但是我已經嘗試了所有解決方案,但沒有一個起作用。 而且他們沒有使用自我托管。
這是我的代碼。
class Program
{
static void Main(string[] args)
{
var config = new HttpSelfHostConfiguration("http://localhost:8080");
config.Routes.MapHttpRoute(
"API Default", "api/{controller}/{action}/{id}",
new { id = RouteParameter.Optional });
using (HttpSelfHostServer server = new HttpSelfHostServer(config))
{
server.OpenAsync().Wait();
Console.WriteLine("Press Enter to quit.");
Console.ReadLine();
}
}
}
public class testController : ApiController
{
[HttpPost]
public string test(int id ,[FromBody]string value)
{
return value;
}
}
我正在使用高級REST客戶端進行測試
這是我的結果
您已將字符串值輸入到請求的標題部分。 您應該在請求正文中發送該值。 例如,放置標頭
Content-Type: application/json
並添加正文(在標頭部分下方,名為raw有效負載 )
"testValue"
注意:考慮使用郵遞員
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.