Created
April 14, 2020 23:12
-
-
Save markrendle/a7eea3b8bcea392291d066ce2f3d4df0 to your computer and use it in GitHub Desktop.
Get server URLs in .NET Core 3.1 app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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