[英]How do you configure Kestrel to use a random dynamic port from a defined range of ports
Is there any way to configure Kestrel to use a random port from a defined range ( for example from 5500 to 5600)?有没有办法将 Kestrel 配置为使用定义范围内的随机端口(例如从 5500 到 5600)?
public class Program
{
public static void Main(string[] args)
{
BuildWebHost().Run();
}
public static IWebHost BuildWebHost() =>
WebHost.CreateDefaultBuilder()
.UseKestrel()
.UseUrls("http://127.0.0.1:0") // port zero to use random dynamic port but doesn't respoect the range port
.UseStartup<Startup>()
.Build();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.