.NET Core 项目未读取 launchSettings.json
.NET Core project not reading launchSettings.json
我有一个使用 .NET Core 3.1 的 Web 应用程序,一切正常启动:
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
唯一的问题是这些端口不是我的 launchSettings.json 文件中指定的端口。
一个小背景:本来这两个本地主机都在 launchSettings.json 文件中指定,然后我去掉了 5001,它只启动了 5000,这正是我想要的。
5001 突然回来了,无论我在 launchSettings.json 文件中进行什么更改,它都会恢复为 5000 和 5001,我删除了 launchSettings.json 文件,它仍然在听在同一个 address/ports 上,我不知道它是从哪里读取的。
仅供参考,这是我当前的 launchSettings.json 文件,它应该是从 StudentsWebApp 配置文件中读取的:
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:61527",
"sslPort": 44325
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"StudentsWebApp": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"applicationUrl": "http://localhost:5005",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
这就是我 运行 网络应用程序的方式,只需单击启动项目的播放按钮或 F5:
为什么它绕过我的 launchSettings.json 文件?
经过更多搜索后,我让它工作了:
在项目属性 > 调试选项卡 > 应用程序参数中添加这个
--urls=http://localhost:5000/
这样它就可以准确读取 address/port 您想要的内容。
我有一个使用 .NET Core 3.1 的 Web 应用程序,一切正常启动:
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
唯一的问题是这些端口不是我的 launchSettings.json 文件中指定的端口。
一个小背景:本来这两个本地主机都在 launchSettings.json 文件中指定,然后我去掉了 5001,它只启动了 5000,这正是我想要的。
5001 突然回来了,无论我在 launchSettings.json 文件中进行什么更改,它都会恢复为 5000 和 5001,我删除了 launchSettings.json 文件,它仍然在听在同一个 address/ports 上,我不知道它是从哪里读取的。
仅供参考,这是我当前的 launchSettings.json 文件,它应该是从 StudentsWebApp 配置文件中读取的:
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:61527",
"sslPort": 44325
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"StudentsWebApp": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"applicationUrl": "http://localhost:5005",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
这就是我 运行 网络应用程序的方式,只需单击启动项目的播放按钮或 F5:
为什么它绕过我的 launchSettings.json 文件?
经过更多搜索后,我让它工作了:
在项目属性 > 调试选项卡 > 应用程序参数中添加这个
--urls=http://localhost:5000/
这样它就可以准确读取 address/port 您想要的内容。