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

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

    Go to your program.cs file add UseUrs method to set your url, make sure you don't use a reserved url or port

     public class Program
        {
            public static void Main(string[] args)
            {
                BuildWebHost(args).Run();
            }
    
            public static IWebHost BuildWebHost(string[] args) =>
                WebHost.CreateDefaultBuilder(args)
                    .UseStartup()
    
                    // params string[] urls
                    .UseUrls(urls: "http://localhost:10000")
    
                    .Build();
        }
    

提交回复
热议问题