本地默认是 http://localhost:5000
,在 docker 中可能是 http://localhost:80
,那么如何在 Startup.Configure()
中获取这个 host url
呢?
通过 urls 配置,详见 Server URLs
public class Startup
{
public void Configure(IApplicationBuilder app, IConfiguration conf)
{
app.Run(async (context) =>
{
await context.Response.WriteAsync(conf["urls"]);
});
}
}
你看一下这个帖子对你有帮助没:
https://q.cnblogs.com/q/89175/
var url= configuration.GetValue(typeof(String), "URLS");