-
Notifications
You must be signed in to change notification settings - Fork 25.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
appsettings Urls takes precedence over ASPNETCORE_URLS in 6.0.4 #25626
Comments
This comment was marked as outdated.
This comment was marked as outdated.
If you want an environment variable to override dotnet/aspnetcore#39836 is a bugfix and it aligns The order of default config in .NET 6 for all hosts after this bugfix is as follows from highest to lowest precedence: Application config
Host config
ExplanationApplication config falls back to host config, so you might wonder why command line arguments gets added again at a lower precedent in host config. And the answer is that when initializing the Since we wanted to allow command-line arguments to control things like environment name by default (and that is important for building application config because that determines which appsettings.{Environment}.json to load), the command line gets added twice as a config source. Host variablesThe following variables are all locked in early when initializing the host builders and cannot be influenced by application config:
@Rick-Anderson Do you think https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-6.0#default-configuration can get updated to be more like the above? I can submit a PR myself, but it might have to wait a little. It is odd that |
I'll give it a shot and have you review the PR. |
Is there an existing issue for this?
Describe the bug
Using aspnet 6.0.4 runtime, precedence of appsettings.json
Urls
andASPNETCORE_URLS
seems to be different compared to previous versions. SpecifyingASPNETCORE_URLS
environment variable does not override the url provided in appsettings.jsonUrls
property. Before 6.0.4,ASPNETCORE_URLS
would have been used overUrls
in appsettings.json .I would assume that the order that these settings are overriden in is the same as for regular settings: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-6.0#default-configuration
Based on those, environment variables are applied after appsettings.
I am guessing this is related to dotnet/aspnetcore#39836 which meant to fix in-code overriding of any configuration value. Also, while that issue is tagged with 6.0.3, based on comment dotnet/aspnetcore#40614 (comment) it looks like it was shipped as part of 6.0.4, which is a bit confusing.
Expected Behavior
ASPNETCORE_URLS
is used instead of appsettings.jsonUrls
.Steps To Reproduce
dotnet new webapi
appsettings.json
by adding"Urls": "http://*:5300/"
export ASPNETCORE_URLS="http://*:5200/"
dotnet run
@Rick-Anderson EDIT following lines
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: