Asp.net core HttpsRedirectionMiddleware Failed to determine the https port for redirect

79,827

Solution 1

See the documentation for various ways of configuring a non-default HTTPS port.

Which approach suits your scenario best depends on how your application is set up and hosted. You could for example add a setting:

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        .UseSetting("https_port", "5001")
        .UseStartup<Startup>();

Solution 2

I had this warning on debug mode. You just need to "Enable SSL" and the warning goes away.

enter image description here

Or if you use IIS, you can edit the Advanced Settings to enable https. enter image description here

Share:
79,827
NewtonCode
Author by

NewtonCode

Updated on January 09, 2021

Comments

  • NewtonCode
    NewtonCode over 3 years

    I am trying to host an ASP.net Core Web Application in a windows service. I am able to create a self contained deployment and created the windows service. My web application is configured to have port 5000 for http and 5001 for https. Within the application , I use a HttpsRedirectMiddleware.

    When I start the windows service , it is only possible to browse the web page over http and throws following error from the Https redirect middleware.

    Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware Failed to determine the https port for redirect.

    Is there any extra configuration needed to expose a port for https communication?

    Github Code Sample