在我的BuildWebHost的红隼部分,我可以验证该网址是否设置为https://localhost/5000。但是,当调用host.run()时,由于某种原因仅启动https://localhost
。
`
.UseKestrel(options =>
{
X509Certificate2 certificate = null;
if (!string.IsNullOrEmpty(certFileName) && !string.IsNullOrEmpty(certPassword))
{
certificate = new X509Certificate2(certFileName, certPassword);
url = "https://localhost:5000";
}
options.Listen(IPAddress.Loopback, 5000, listenOptions =>
{
if (certificate != null)
{
listenOptions.UseHttps(certificate);
}
});
})
`
其他信息: 它在我运行Visual Studio Code时启动。我的配置文件都说localhost:5000这曾经工作过。我将launch.json中的程序属性更改为指向net2.0路径,并且当它停止时。
launch.json内容: `
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
// "program": "${workspaceFolder}/bin/Debug/netcoreapp1.1/TennisFolderAPI.dll",
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.0/TennisFolderAPI.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
},
"requireExactSource": false,
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
`
答案 0 :(得分:1)
对于launchSettings.json中的Visual Studio,请使用“launchUrl”:“http://localhost:5000”。
Launch.json适用于Visual Studio Code。
https://www.google.com/amp/s/andrewlock.net/how-to-set-the-hosting-environment-in-asp-net-core/amp/