Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get server URLs in .NET Core 3.1 app
public static async Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
var task = host.RunAsync();
var serverAddresses = host.Services.GetRequiredService<IServer>()
.Features
.Get<IServerAddressesFeature>();
foreach (var serverAddress in serverAddresses.Addresses)
{
Console.WriteLine(serverAddress);
}
await task;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.