I changed the order of HTTP and HTTPS profile definitions. And as seen in the screenshot, both ports started to work actively. However, a new WARN appeared on the console.
How to fix this error "warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3] Failed to determine the https port for redirect."
Good evening , I am trying to build a simple web api using ASP.Net . The app has been showing the error like this after building it -
warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
Failed to determine the https port for redirect.
I have built according to this documentation-
https://learn.microsoft.com/en-in/training/modules/build-web-api-aspnet-core/3-exercise-create-web-api
9 answers
Sort by: Most helpful
-
-
Scott Zeta 5 Reputation points
2024-03-21T08:03:39.9433333+00:00 Run
dotnet run --launch-profile https
Both ports are valid in browser and httprepl If you are going to do Razor app tutorial
dotnet watch --launch-profile https
This can work as well, but if you try to access the page in http port in browser you will be redirect to https port. I guess because http page is not encouraged in browser anymore.
Unless you comment out this line in Program.cs
app.UseHttpsRedirection();
Then you can vist pages under different protocals.
Reference: https://github.com/dotnet/sdk/issues/29569
-
Doris Ann Augustine 0 Reputation points
2023-09-28T15:17:48.9333333+00:00 Has anyone been able to solve this? All the solutions above didn't work for me.
-
Giray Turker 0 Reputation points
2024-05-01T01:40:34.87+00:00 Watch dotnet run if there is https connection setting for existing project with;
dotnet watch -lp https
if you have profile for https, the connection automatically will open with your browser. Otherwise, create new https connection!
If https connection exist:
1 - Open the launchSettings.json file.
2 - Find the section where your profiles are listed.
3 -Change the order of the profiles so that the HTTPS profile is listed first.
4 - Save the changes to the launchSettings.json file.
RESULT: