dotnet运行命令未在https上侦听



我在Windows上运行一个简单的ASP.Net程序,当我尝试运行"dotnet run"命令时,我可以看到它只在http上侦听,而不在https上侦听。我还执行了"dotnet-dev-certs-https--trust"命令来信任开发证书,但它仍然没有在https上侦听。如果我缺少任何其他设置,你能告诉我吗?

PS C:UserstestDocumentsTodoApi> dotnet  run 
Building...
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5027
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:UserstestDocumentsTodoApi

lanuchsettings.json

{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:40409",
"sslPort": 44321
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5027",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7130",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

您可以在启动类中使用HostingAbstractionsWebHostBuilderExtensions.UseUrls方法。如果你想在命令行中传递url,那么使用

dotnet run --urls "https://localhost:5027"

最新更新