无法从命令行更改隼监听端口
问题描述:
我有以下入口点:无法从命令行更改隼监听端口
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("hosting.json", optional: true)
.AddCommandLine(args)
.AddEnvironmentVariables()
.Build();
var host = new WebHostBuilder()
.UseConfiguration(config)
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
它的工作原理,如果我添加hosting.json文件中像
{
"server.urls": "http://0.0.0.0:5001"
}
,或者如果我定义的环境变量(有发现名称here)
SET ASPNETCORE_URLS=https://0.0.0.0:5001
但是,如果我通过--server.urls http://0.0.0.0:5001
为paramete R,应用程序侦听默认端口5000:
> dotnet run --server.urls http://0.0.0.0:5001
...
Now listening on: http://localhost:5000
答
正确的语法是
dotnet run --server.urls=http://0.0.0.0:5001
,而不是
dotnet run --server.urls http://0.0.0.0:5001
详情请参阅the old answer。
你使用的是什么确切版本的dotnet? –
@DirkVollmar dotnet --version返回1.0.0-preview2-003121 – Set
请尝试更新到最新版本,然后(如果Oleg的答案尚未解决您的问题)。 –