我有一个ASP.NET Core 2.0 WEB-API,它应该可以在kestrel上运行,因为它将在那里托管。当我开始使用 Kestrel(查看下面的 launchSettings)时,有一个 POST,我总是得到500 返回,而无需进入代码。意味着我到处都留下了断点,当我在 Swagger 中执行 POST 时,没有断点被击中。当我改用 IIS 时,它工作正常。500 马上就来了。500 也是在 Linux Kestrel 上部署后出现的。
我实现@Startup.cs:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.Use((context, next) =>
{
context.Response.Headers.Remove("Server");
return next();
});
@程序.cs:
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls("http://0.0.0.0:5000")
.UseIISIntegration()
.UseApplicationInsights()
.UseKestrel()
.Build();
@launchSettings.json:
"Kestrel": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
使用 Kestrel,POST 调用应该使用与 IIS 相同的所有逻辑来处理 Controller 方法。
撒科打诨
慕的地10843
随时随地看视频慕课网APP
相关分类