[英]How to override default ports in Kestrel
i have simple method我有简单的方法
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(builder => builder.UseStartup<Startup>());
}
and i am write appsettings:我正在写应用程序设置:
"Kestrel": {
"EndpointDefaults": {
"Protocols": "Http1AndHttp2"
},
"Endpoints": {
"Api": {
"Url": "https://+:5005",
"Protocols": "Http1AndHttp2"
},
"Grpc": {
"Url": "http://+:5006",
"Protocols": "Http2"
}
}
}
but when i start app, i see warning:但是当我启动应用程序时,我看到警告:
"Microsoft.AspNetCore.Server.Kestrel", "message": "Overriding address(es) 'https:\/\/localhost:5000, https:\/\/localhost:5001'. Binding to endpoints defined in UseKestrel() instead.", "addresses": "https:\/\/localhost:5000, https:\/\/localhost:5001
", "methodName": "UseKestrel()" }
and app start at standard port 5000, but i expect on port 5005和应用程序从标准端口 5000 开始,但我希望在端口 5005
Why Kestrel changes the start port and how to make the application start on a given https://localhost:5005/api-docs/someService (i am use swagger)为什么 Kestrel 更改启动端口以及如何使应用程序在给定的 https://localhost:5005/api-docs/someService 上启动(我使用 swagger)
As said on your application startup just do it in UseKestrel()
正如您在应用程序启动时所说,只需在
UseKestrel()
中执行即可
return Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(builder => builder.UseKestrel(x=>x.Listen(IPAddress.Any, 5005)).UseStartup<Startup>());
i am find that i need feel launchSettings.json with我发现我需要使用 launchSettings.json
"launchUrl": "https://localhost:5005/api-docs/SomeService"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.