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

后端 未结 12 1010
误落风尘
误落风尘 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:16

    you can also code like this

            IConfiguration config  = new ConfigurationBuilder()
            .AddCommandLine(args)
            .Build(); 
            var host = new WebHostBuilder()
             .UseConfiguration(config)
             .UseKestrel()
             .UseContentRoot(Directory.GetCurrentDirectory()) 
             .UseStartup()
             .Build();
    

    and set up your application by command line :dotnet run --server.urls http://*:5555

提交回复
热议问题