1
我想用hosting.json
文件手動覆蓋服務器網址,但是網址永遠不會被使用。我在.net核心2.0。ASP.NET核心:hosting.json網址未加載
hosting.json:
{
"urls": "http://localhost:5000"
}
的Program.cs:
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args)
{
IConfigurationRoot config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("hosting.json", optional: true)
.AddCommandLine(args)
.Build();
return WebHost.CreateDefaultBuilder(args)
.UseConfiguration(config)
.UseStartup<Startup>()
.Build();
}
}