The issue that I have is simple. I want to access the server URL in my IHostedService
.
I cannot find a way to do it. There isn't any request there so I cannot use the IHttpContextAccessor
.
IServer
features property doesn't have any addresses and I am out of options.
I do not want to hard code the URL of the server in the configuration.
The version of .NET core that I am running is 3.0.
You cannot get the address/url from your server before you completely start the server.
If you need your localhost address, look it up (programmatically or otherwise) from ./Properties/launchSettings.json
.
If you need the address in a live environment, you have to wait for the server to load.