I'm trying to use ASP.NET Core 2.0's new way of configuring Kestrel endpoints via settings in appsettings.json. This was demonstrated at the Microsoft Build 2017 event (see it on YouTube timeframe 21:00-26:20).
The speaker said (and demonstrated) that the following would configuring the listening ports on Kestrel:
{
"Message": "TEST!!",
"Kestrel": {
"Endpoints": {
"Localhost": {
"Address": "127.0.0.1",
"Port": "5011"
}
}
}
}
But this hasn't worked for me. When I use 'dotnet run', the default port of 5000 is still being used. I know the appsettings.json file is being loaded, because I can use the Message value elsewhere.
From the code on GitHub, I can't see any place where Kestrel is being configured.
Has anyone else been able to get this method to work? I can't understand how it works in the demo but not in my own code.
Unfortunately that doesn't work anymore. Check out How to use Kestrel in ASP.NET Core apps . So it doesn't really work with settings anymore. You can do something like the this in you program.cs. Here's I'm setting things up to use https locally but you get the general idea...
}