How to Start the HTTPS Port for Your ASP.NET MVC Application
When we run our ASP.NET application from the command line, we see that it only starts the HTTP port:
info: Microsoft.Hosting.Lifetime[14] Now listening on: https://localhost:5155 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\jg\source\repos\WebApplication1\WebApplication1
However, if we start the same application inside Visual Studio, we also get the HTTPS port:
info: Microsoft.Hosting.Lifetime[14] Now listening on: https://localhost:7150 info: Microsoft.Hosting.Lifetime[14] Now listening on: https://localhost:5155 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\jg\source\repos\WebApplication1\WebApplication1
This difference comes from a change in the default behaviour in .Net. Since .Net 7 the dotnet command only starts the first configuration in our launchSettings.json file.
To get the same behaviour on the command line, we need to add **--launch-profile https** as a parameter:
info: Microsoft.Hosting.Lifetime[14] Now listening on: https://localhost:7150 info: Microsoft.Hosting.Lifetime[14] Now listening on: https://localhost:5155 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\jg\source\repos\WebApplication1\WebApplication1
I hope this helps when you search for the missing HTTPS port of your .Net web application.