我想改变默认的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"
}
}
}
}
4条答案
按热度按时间vmdwslir1#
你需要在构建“BuildWebHost”时添加url。希望这对你有帮助https://github.com/aspnet/KestrelHttpServer/issues/639
下面是我在。net核心2.0控制台应用程序中使用的代码
控制台输出的屏幕截图:
piztneat2#
使用Kestrel,您可以使用hosting.json文件指定端口。
将hosting.json添加到您的项目中,并包含以下内容:
并添加到project.json中的publishOptions
以及在创建WebHostBuilder时应用程序调用“.UseConfiguration(config)”的入口点中:
8nuwlpux3#
如果您希望此按钮再次与您想要的端口一起工作
删除项目文件夹中的
bin/Debug
,并感到高兴r7s23pms4#
我遇到了类似的问题,在launchSettings.json中更改applicationUrl无效。
最后发现在
appsettings.json
或appsettings.Development.json
中被该项覆盖