AspNetCore RC2: Kestrel server won't bind to multiple server.urls
See original GitHub issueThe server is not honoring server url bindings when launching web apps using .Net Core RC2 VS tools, eg this doesn’t work:
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseUrls("http://localhost:60000", "http://localhost:60002")
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
However, everything works fine when launching this way:
project-root > dotnet run
I’ve been digging around, and can’t find much on this topic other than a few related issues:
- https://github.com/aspnet/Announcements/issues/174
- http://stackoverflow.com/questions/34212765/how-do-i-get-the-kestrel-web-server-to-listen-to-non-localhost-requests
I tried moving the urls to a server.urls variable in an external hosting.json file and using the configuration builder as suggested in the 2nd link, but that’s not working either.
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("hosting.json", optional: true)
.Build();
var host = new WebHostBuilder()
.UseKestrel()
.UseConfiguration(config)
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
// contents of hosting.json,
// {
// "server.urls": "http://localhost:60000 http://localhost:60002"
// }
The hosting.json file is located in the project root along side project.json and was created based on the only example I could find:
Although seemlingly promising, that didn’t work either.Are you having this issue too or has anyone else reported it?
I’m using 1.0.0-preview1-002702.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
I’m going to close this issue. It’s not related to SaasKit, and it’s easy enough to fix by doing the following:
\.vs\config\applicationhost.config
file<bindings></bindings>
Before
After
It’s an issue with IIS Express, and yes, changing ApplicationHost.config is the way to resolve it.