问题可能是由于Kestrel服务器仅默认使用https,因此需要配置http才能使其工作。
dotnet dev-certs https -v -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p Your_password123
dotnet dev-certs https --trust
该命令将创建和信任一个自签名的https证书,以便使用http。确保替换密码参数为实际密码。
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://localhost:5000"
},
"Https": {
"Url": "https://localhost:5001",
"Certificate": {
"Path": "c:\\certs\\aspnetapp.pfx",
"Password": "Your_password123"
}
}
}
}
此代码将配置kestrel以同时使用http和https。确保替换密码参数和证书路径为对应的值。