Skip to content

appsettings Urls takes precedence over ASPNETCORE_URLS in 6.0.4 #25626

Closed
@Hoffs

Description

@Hoffs

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Using aspnet 6.0.4 runtime, precedence of appsettings.json Urls and ASPNETCORE_URLS seems to be different compared to previous versions. Specifying ASPNETCORE_URLS environment variable does not override the url provided in appsettings.json Urls property. Before 6.0.4, ASPNETCORE_URLS would have been used over Urls 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.json Urls.

Steps To Reproduce

  • Create new project dotnet new webapi
  • Modify appsettings.json by adding "Urls": "http://*:5300/"
  • Set env var export ASPNETCORE_URLS="http://*:5200/"
  • dotnet run
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://[::]:5300

@Rick-Anderson EDIT following lines


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions