I've recently updated a project from netcoreapp 2.2 to 3.0. When I debug the project locally it is running on the default ports 5000
and 5001
.
I have specified specific urls in both UseUrls
and the launchsettings.json
file, but they are all being ignored.
Any idea why these configurations are not being picked up, and why it is resorting to using the default ports? Thanks.
CodePudding user response:
It could be related to sequence of adding services
Can you try to change it to this:
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.UseUrls("https://localhost:8081", "http://localhost:8080");
});
CodePudding user response:
Found the issue.
Our solution was not using the Startup
's constructor to access the instance of IConfiguration
. We had a convenience method doing this to only grab the appsettings.json
config, meaning we missed out on any other config .NET Core needed for setting up the app. This wasn't required in 2.2, but obviously is now.
Hope this helps anyone else.
Solution
Get IConfiguration
via Startup
constructor: