From 6b9e0cbf5ef578487e617678b882489217690d07 Mon Sep 17 00:00:00 2001 From: b-stime <34577613+b-stime@users.noreply.github.com> Date: Wed, 20 Dec 2017 14:08:31 -0600 Subject: [PATCH] Attempts to fix urls from appsettings.json, CLI WebHost checks _config for the deprecated "server.urls" key but it also checks _config for the new key . I believe it should use _startup.Configure for the new key. The ultimate problem I'm trying to solve is that: WebHost.CreateDefaultBuilder(args) .UseStartup() .Build(); ...doesn't read the urls from appsettings.json or the command line. I haven't tested this change--I'm editing via the GitHub web interface. --- src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs b/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs index 3764427f..e1fb5c2a 100644 --- a/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs +++ b/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs @@ -287,7 +287,7 @@ private void EnsureServer() var addresses = serverAddressesFeature?.Addresses; if (addresses != null && !addresses.IsReadOnly && addresses.Count == 0) { - var urls = _config[WebHostDefaults.ServerUrlsKey] ?? _config[DeprecatedServerUrlsKey]; + var urls = _startup.Configure.GetSection(WebHostDefaults.ServerUrlsKey).Get() ?? _config[DeprecatedServerUrlsKey]; if (!string.IsNullOrEmpty(urls)) { serverAddressesFeature.PreferHostingUrls = WebHostUtilities.ParseBool(_config, WebHostDefaults.PreferHostingUrlsKey);