Closed glennc closed 8 years ago
I think templates should use the following, instead of hardcoding http://localhost:5000
:
UseUrls(Environment.GetEnvironmentVariable("ASPNETCORE_URLS"))
If the environment variable is not set, then UseUrls(null)
will be called, and Hosting will use the default of http://localhost:5000
.
What would be the experience if you have a team and some use VS and others editors like VS Code or Notepad++? For the VS users, we can take care of setting the env var. For the other users, if I understand this correctly, it would require them to set an env var on the command prompt for each project that needs to be launched. The local url of the app is important because users will refer to a particular url for local development in other projects.
@sayedihashimi I think for non-docker scenarios, we wouldn't set the environment variable and then hosting would just use localhost:5000 like Mike mentioned, thus keeping the same behavior we have today.
Docker would set the environment variable for their runtime scenario.
Correct, there should be no difference from current behavior if the environment variable is not set. UseUrls(null)
is a no-op. This just makes it easier for Docker Tooling (or any other customer scenarios) to change the address via environment variable.
We didn't want to add a fixed environment variable for this in the framework itself (in part because it's not discoverable), but it seems reasonable in a template, and serves as documentation for how to change the URL.
I see so this is independent of IIS Express, I missed that part.
This isn't needed now that WebHostBuilder will read the variable itself instead of having to have it passed in.
@mikeharder I was fairly sure UseUrls throws if is passed null. We could change that of course.
This will allow the Docker tools team to not modify user code after a new app is created.