admin管理员组文章数量:1390895
Question
Why does dotnet run
in my ASP.NET Core Web API use http
only, and not using https
, as well?
Details
I am working on Exercise - Create a minimal API from the ASP.NET team. According to item 3 of Scaffold a Project
section of this exercise, the output of dotnet run
command should also include https
path, say, https://localhost:7200
.
But, on my Windows 10 machine, the output includes only http
path (as shown below) despite the fact that I have first run the dotnet dev-certs https --trust
to trust the self-singing certificate.
Command to trust the certificate
PS C:\Users\MyUserName> dotnet dev-certs https --trust
Trusting the HTTPS development certificate was requested. A confirmation prompt will be displayed if the certificate was not previously trusted. Click yes on the prompt to trust the certificate.
Successfully trusted the existing HTTPS certificate.
Output of dotnet run
PS C:\Users\MyUserName\PizzaStore> dotnet run
Using launch settings from C:\Users\MyUserName\PizzaStore\Properties\launchSettings.json...
Building...
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5192
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:\Users\MyUserName\PizzaStore
Question
Why does dotnet run
in my ASP.NET Core Web API use http
only, and not using https
, as well?
Details
I am working on Exercise - Create a minimal API from the ASP.NET team. According to item 3 of Scaffold a Project
section of this exercise, the output of dotnet run
command should also include https
path, say, https://localhost:7200
.
But, on my Windows 10 machine, the output includes only http
path (as shown below) despite the fact that I have first run the dotnet dev-certs https --trust
to trust the self-singing certificate.
Command to trust the certificate
PS C:\Users\MyUserName> dotnet dev-certs https --trust
Trusting the HTTPS development certificate was requested. A confirmation prompt will be displayed if the certificate was not previously trusted. Click yes on the prompt to trust the certificate.
Successfully trusted the existing HTTPS certificate.
Output of dotnet run
PS C:\Users\MyUserName\PizzaStore> dotnet run
Using launch settings from C:\Users\MyUserName\PizzaStore\Properties\launchSettings.json...
Building...
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5192
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:\Users\MyUserName\PizzaStore
Share
Improve this question
edited Mar 16 at 17:38
marc_s
756k184 gold badges1.4k silver badges1.5k bronze badges
asked Mar 16 at 17:28
namnam
24k45 gold badges189 silver badges402 bronze badges
0
1 Answer
Reset to default 2We can find launchSettings.json
file under the Properties
folder.
Under profiles
, we can see that the first default is http
, the second is https
, and the third is IIS Express
. When we execute dotnet run, the default startup item will use http
.
So there are 2 ways to fix the issue.
1. Use below command to start the application manually.
dotnet run --launch-profile https
2. Change the https order in profiles
{
"$schema": "http://json.schemastore./launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:41731",
"sslPort": 44378
}
},
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7188;http://localhost:5108",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5108",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Then run the command dotnet run
, it will use https by default.
本文标签: ASPNET Core Web API routing is not using httpsStack Overflow
版权声明:本文标题:ASP.NET Core Web API routing is not using https - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744591581a2614523.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论