How to change the port number for Asp.Net core app?

后端 未结 12 988
误落风尘
误落风尘 2020-12-05 01:34

I added the following section in project.json.

  \"commands\": {
    \"run\": \"run server.urls=http://localhost:8082\",
    \"web\": \"Microsof         


        
12条回答
  •  春和景丽
    2020-12-05 02:31

    Yes this will be accesible from other machines if you bind on any external IP address. For example binding to http://*:80 . Note that binding to http://localhost:80 will only bind on 127.0.0.1 interface and therefore will not be accesible from other machines.

    Visual Studio is overriding your port. You can change VS port editing this file Properties\launchSettings.json or else set it by code:

            var host = new WebHostBuilder()
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup()
                .UseUrls("http://*:80") // <-----
                .Build();
    
            host.Run();
    

    A step by step guide using an external config file is available here.

提交回复
热议问题