In my case, I just ran this command in my CLI from the Root Directory, and it just Fired up:
dotnet watch -lp https
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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
In my case, I just ran this command in my CLI from the Root Directory, and it just Fired up:
dotnet watch -lp https
In my case it works when I delete the "http" of the "profiles" section in launchSettings.json like this:
Hi @Vaishnavi P
How to fix this error "warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3] Failed to determine the https port for redirect."
From the issue message, it seems that you might not specified the HTTPS port in your configuration or if you have multiple HTTPS ports in your server configuration.
Check the Properties/launchSettings.json
file, when using dotnet run
command to run the application, it will run the application on Kestrel Development environment and the request url is setting via the applicatonUrl
property.
For example, according to the tutorial, I create a sample on my side, the result as below:
You can try to change the port in the applicationUrl.
ASP.NET Core projects are configured to bind to a random HTTP port between 5000-5300 and a random HTTPS port between 7000-7300. This default configuration is specified in the generated Properties/launchSettings.json
file and can be overridden. If no ports are specified, Kestrel binds to http://localhost:5000
. More detail information, see Configure endpoints for the ASP.NET Core Kestrel web server.
Finally, if still not working, can you tell us which version of the .NET SDK you are using? And it is better to create a simple sample to reproduce the problem and share it with us, it is easier for us to help you find the issue.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion
I solved this by adding the following to my appsettings.json
to configure [Kestrel] the default webserver for ASP.NET
{
"Kestrel": {
"Endpoints": {
"Https": {
"Url": "https://localhost:5001"
}
}
}
}
on my windows machine this warning was because i did not add certification to the cert center
after this 2 steps it solved
dotnet tool install -g Microsoft.dotnet-httprepl
dotnet dev-certs https --trust