我得到了一个ASP.NET Core2.0Web-api,它应该可以在kestrel上工作,因为它将是在那里的主机。当我从Kestrel开始(看看下面的launchSettings )时,会有一个帖子,我总是得到一个500返回,而没有进入代码。这意味着我在任何地方都会留下断点,当我在Swagger中执行POST时,不会命中断点。当我使用IIS时,它可以正常工作。500辆马上就到了。500也是在Linux上部署之后出现的。
我实现了@Startup.cs:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.Use((context, next) =>
{
context.Response.Headers.Remove("Server");
return next();
});@Program.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调用应该用它的所有逻辑处理Controller方法,就像IIS一样。
发布于 2019-04-03 12:38:58
我让它和
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseIISIntegration()
.UseApplicationInsights()
.UseKestrel(options =>
{
options.Listen(IPAddress.Parse("0.0.0.0"), 5000);
})
.Build();以及发射装置:
"CZKestrel": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:59883/"
}用于本地调试。
为了使它作为服务工作,我做了dotnet还原和dotnet构建,我只将带有创建的dll的文件夹复制到另一个地方,而不是运行/启动服务。我想当我启动它时,我应该在dll文件夹之上的一个文件夹中。现在起作用了。
https://stackoverflow.com/questions/55478656
复制相似问题