Skip to content

Instantly share code, notes, and snippets.

@doronguttman
Last active November 29, 2021 16:29
Show Gist options
  • Save doronguttman/ba1747c74694cfa141a1db5e119e913f to your computer and use it in GitHub Desktop.
Save doronguttman/ba1747c74694cfa141a1db5e119e913f to your computer and use it in GitHub Desktop.
Get First Kestrel Endpoint Address
// Type: Microsoft.AspNetCore.Hosting.Server.Features.IServerAddressesFeature
// Assembly: Microsoft.AspNetCore.Hosting.Server.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
// using Microsoft.AspNetCore.Hosting.Server.Features;
public void Configure(IApplicationBuilder app)
{
var address = app.ServerFeatures
.Select(i => i.Value)
.OfType<IServerAddressesFeature>()
.SelectMany(f => f.Addresses)
.First();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment