gpt4 book ai didi

LaunchSettings.json中的Asp.Net Core更改URL不起作用

转载 作者:行者123 更新时间:2023-12-04 18:03:15 31 4
gpt4 key购买 nike

当我将网站作为控制台应用程序运行时,我想更改默认URL(http://localhost:5000)。

我编辑了launchSettings.json但它不起作用...它仍然使用端口5000:

    {
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:4230/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"website": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "http://localhost:80",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

最佳答案

生成“BuildWebHost”时,需要添加URL。希望这对您有帮助https://github.com/aspnet/KestrelHttpServer/issues/639

以下是我在.net core 2.0控制台应用程序中使用的代码

public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}

public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls("http://localhost:5050/")
.Build();


}

Screenshot of the console output

关于LaunchSettings.json中的Asp.Net Core更改URL不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38314636/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com