Has anyone been able to solve this? All the solutions above didn't work for me.
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://video2.skills-academy.com/en-in/training/modules/build-web-api-aspnet-core/3-exercise-create-web-api
10 answers
Sort by: Most helpful
-
-
Mehmet Cenk Yenikoylu 5 Reputation points
2023-12-11T11:00:56.1+00:00 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.
-
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
-
Giray Turker 5 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:
-
Deleted
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more