Home > database >  Why does Visual Studio compile my HTTP server app to run on port 5001 when I set it to 443/80?
Why does Visual Studio compile my HTTP server app to run on port 5001 when I set it to 443/80?

Time:02-06

Is there a separate place from launchsettings.json I need to set the applicationUrl?

Here's the launch setting

"applicationUrl": "https://127.0.0.1:443;http://127.0.0.1:80"

Here's a picture of the app when running inside Visual Studio enter image description here

Here's a picture of it running from the compiled exe (release & debug) enter image description here

CodePudding user response:

launchSettings.json used during development, for example, run from the visual studio or using dotnet run command.

If you want to configure the URL when run compiled exe, could add this:

"Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://127.0.0.1:80"
      },
      "Https": {
        "Url": "https://127.0.0.1:443"
      }
    }
  }

to the file appsettings.json or Program.cs.

CodePudding user response:

The config file launchSettings.json is only honored in a few places, such as

  • Debug from Visual Studio
  • dotnet run

So if you find it ignored, you know clearly that's by design and you should use other ways to configure Kestrel ports,

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/endpoints?view=aspnetcore-6.0#url-prefixes

  •  Tags:  
  • Related