Redirecting to port 5001

I am running into a weird issue and would appreciate your help in figuring out what is causing it. Some background information is as follows: I am using Windows Server 2022 and “Certify the Web” client. There are a few ASP.NET Core apps on this server.

The issue I am experiencing is that occasionally, when I go to the website, I get redirected to port 5001 for some reason. When I subsequently remove the port from the URL, it works as expected. Do you know what might be causing the redirect and why the port is being appended to the host URL?
PS: I always get this issue the 1st time I add the site.

I have a hunch that it’s caused by “Certify the Web.”

Hi, no this is not directly caused by Certify The Web, we don’t update your web.config, but it could be your configuration is reacting in some odd way to binding updates. We’ve definitely never seen this reported before.

This sounds to me like your dotnet core app (which runs within Kestrel and is proxied via IIS) is not being properly proxied by IIS. You’ll note in your launch settings within visual studio that port 5001 is one of the default ports when developing locally.

  • Which version of dotnet core is your app running
  • Which version of the dotnet hosting bundle do you have installed?
  • Is your app running In Process or Out Of Process?

Review the docs for dotnet, you will see that your app is configured to use the https redirection middleware and that the port you should redirect to (443) needs to be set: Enforce HTTPS in ASP.NET Core | Microsoft Learn