添加host.json文件
{ "urls": "https://localhost:44389;http://localhost:44380" }
在Program.cs中修改CreateWebHostBuilder方法
public static IWebHostBuilder CreateWebHostBuilder(string[] args) { var configuration = new ConfigurationBuilder().SetBasePath(Environment.CurrentDirectory) .AddJsonFile("host.json") .Build(); var url = configuration["urls"]; return WebHost.CreateDefaultBuilder(args) .UseUrls(url) .UseStartup<Startup>(); }
运行