diff --git a/src/Microsoft.AspNet.Hosting/Internal/WebApplication.cs b/src/Microsoft.AspNet.Hosting/Internal/WebApplication.cs index 170a7f26cd..74e95c4bc5 100644 --- a/src/Microsoft.AspNet.Hosting/Internal/WebApplication.cs +++ b/src/Microsoft.AspNet.Hosting/Internal/WebApplication.cs @@ -21,9 +21,6 @@ namespace Microsoft.AspNet.Hosting.Internal { public class WebApplication : IWebApplication { - // This is defined by IIS's HttpPlatformHandler. - private static readonly string ServerPort = "HTTP_PLATFORM_PORT"; - private readonly IServiceCollection _applicationServiceCollection; private readonly IStartupLoader _startupLoader; private readonly ApplicationLifetime _applicationLifetime; @@ -223,19 +220,10 @@ namespace Microsoft.AspNet.Hosting.Internal Server = ServerFactory.CreateServer(_config); var addresses = Server.Features?.Get()?.Addresses; - if (addresses != null && !addresses.IsReadOnly) + if (addresses != null && !addresses.IsReadOnly && addresses.Count == 0) { - var port = _config[ServerPort]; - if (!string.IsNullOrEmpty(port)) - { - addresses.Add("http://localhost:" + port); - } - // Provide a default address if there aren't any configured. - if (addresses.Count == 0) - { - addresses.Add("http://localhost:5000"); - } + addresses.Add("http://localhost:5000"); } } } diff --git a/test/Microsoft.AspNet.Hosting.Tests/WebApplicationTests.cs b/test/Microsoft.AspNet.Hosting.Tests/WebApplicationTests.cs index fcbb01736a..a83818a9cf 100644 --- a/test/Microsoft.AspNet.Hosting.Tests/WebApplicationTests.cs +++ b/test/Microsoft.AspNet.Hosting.Tests/WebApplicationTests.cs @@ -106,24 +106,6 @@ namespace Microsoft.AspNet.Hosting Assert.NotNull(application.Services.GetService()); } - [Fact] - public void CanSpecifyPortConfig() - { - var vals = new Dictionary - { - { "Server", "Microsoft.AspNet.Hosting.Tests" }, - { "HTTP_PLATFORM_PORT", "abc123" } - }; - - var builder = new ConfigurationBuilder() - .AddInMemoryCollection(vals); - var config = builder.Build(); - var application = CreateBuilder(config).Build(); - application.Start(); - Assert.NotNull(application.Services.GetService()); - Assert.Equal("http://localhost:abc123", application.ServerFeatures.Get().Addresses.First()); - } - [Fact] public void CanDefaultAddresseIfNotConfigured() {