简体   繁体   English

如何配置 Kestrel 以使用定义的端口范围中的随机动态端口

[英]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();
}

I don't think we are currently support a ranged dynamic port, checked docs , not saying it is a ranged port我认为我们目前不支持远程动态端口,检查文档,而不是说它是远程端口

I raised a github issue and you can subscribe that to see if this would be a new feature in the future我提出了一个 github问题,您可以订阅该问题,看看这是否会成为未来的新功能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM