in src/Microsoft.ServiceFabric.AspNetCore/WebHostCommunicationListener.cs [49:84]
public async Task<string> OpenAsync(CancellationToken cancellationToken)
{
this.host = this.build(this.listener.GetListenerUrl(), this.listener);
if (this.host == null)
{
throw new InvalidOperationException(SR.WebHostNullExceptionMessage);
}
await this.host.StartAsync(cancellationToken);
var url = this.host.ServerFeatures.Get<IServerAddressesFeature>().Addresses.FirstOrDefault();
if (url == null)
{
throw new InvalidOperationException(SR.ErrorNoUrlFromAspNetCore);
}
var publishAddress = this.serviceContext.PublishAddress;
if (url.Contains("://+:"))
{
url = url.Replace("://+:", $"://{publishAddress}:");
}
else if (url.Contains("://[::]:"))
{
url = url.Replace("://[::]:", $"://{publishAddress}:");
}
// When returning url to naming service, add UrlSuffix to it.
// This UrlSuffix will be used by middleware to:
// - drop calls not intended for the service and return 410.
// - modify Path and PathBase in Microsoft.AspNetCore.Http.HttpRequest to be sent correctly to the service code.
url = url.TrimEnd(new[] { '/' }) + this.listener.UrlSuffix;
return url;
}