据我所知,为了正确地设置ASP Dotnet Core 2 preview 1/2的监听端口,需要按照以下格式在appsettings.json中创建一个Kestrel部分:
"Kestrel": {
"EndPoints": { //Could also be Endpoints, it's a bit unclear
"Http": {
"Address": "127.0.0.1",
"Port": 9001 //the port you want Kestrel to run on
},
我尝试在Debian机器上设置示例Web应用程序,但是当我启动应用程序时,它会写出应用程序正在侦听端口5000(默认端口)的消息。
我知道appsettings.json被读取了,因为当我将日志记录级别更改为Trace时,启动时会收到更多信息,包括未找到终结点并且应用程序将使用标准5000端口。
我已经尝试在Github上搜索aspnet源代码,并且可以找到一个区域,其中从配置中读取Kestrel部分(https://github.com/aspnet/Identity/blob/e38759b8a2de1b7a4a1c19462e40214b43c1cf3b/samples/IdentityOIDCWebApplicationSample/MetaPackage/KestrelServerOptionsSetup.cs),但是正如您所看到的,它看起来像是一个示例项目。
我错过了什么,这不是在ASP Dotnet core 2中配置Kestrel的标准方法吗?