How do I get the kestrel web server to listen to non-localhost requests?

前端 未结 6 1095
日久生厌
日久生厌 2020-11-27 10:39

I\'ve deployed my c#, asp.net 5, mvc 6 app to a windows 2008 server. I\'ve fired up dnx web and it is listening to port 5000 and works fine when accessing from

6条回答
  •  时光取名叫无心
    2020-11-27 11:25

    In RC2 the commands section of project.json is no longer used. I haven't gotten Kestrel to pick up the hosting.json yet, but you can programatically set the port in the Main of the application where the new WebHostBuilder is created and configured. Just add .UseUrls() method like in the sample below

        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseUrls("http://0.0.0.0:5000/")
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup()
                .Build();
    
            host.Run();
        }
    

提交回复
热议问题