我想将我的WebAPI注册到Consul服务发现中,为此,我应该提供我的WebAPI的URL(例如:http ://service1.com )和运行状况检查端点(http://service1.com/health/check)。如何获得该URL?
我找到了这段代码:
var features = app.Properties["server.Features"] as FeatureCollection;
var addresses = features.Get<IServerAddressesFeature>();
var address = addresses.Addresses.First();
var uri = new Uri(address);
Run Code Online (Sandbox Code Playgroud)
它返回127.0.0.1:16478而不是localhost:5600。我认为第一个由dotnet.exe使用,第二个是IIS,它将5600转发到16478。如何在Startup.cs中获得localhost:5600?