Closed zhenmin-peng closed 6 years ago
There are a two issues at work here:
launchSettings.json makes the CLI set the ASPNETCORE_URLS
environment variable before running the program. As you can see in the sample Program.cs, there is no capturing of environment variables implemented so parameter is added to the service registration.
There is a bug in ASP.NET Core's default WebHost builder that prevents the app's command line config to actually set the URL. This will be fixed in 2.1.0 but until then it requires a workaround. See https://github.com/aspnet/MetaPackages/issues/221
I'll fix number 2 by adding the workaround to the sample app so that dotnet run …… --urls http://*:50250
will work (since that may be needed in production) but I'd rather not bloat it with trying to read development-time settings.
@alphaeleven I've merged the workaround in https://github.com/dasMulli/dotnet-win32-service/pull/53.
Is that sufficient information for you?
I'm not sure if I should make any efforts to fix (1) since it really seems a little out of scope for a sample..
@dasMulli Thank you so much for your quick response and fix.
The workaround does the trick. And agree that there is no need to do the fix (1) as it is a bit irrelevant.
Run the following cmds in elevated powershell prompt
And open up http://localhost:50250/ (url is from launchsetting.json) but says "This site can’t be reached"
Also tried it in the interactive mode which seemed to work fine.
Anything else I forgot to do to make it work? Many thanks.