简体   繁体   中英

Microservice not Launching on Port Set by LaunchSettings.JSON

I'm trying to debug a Microservice.When running from VS,it launches in the port set in LaunchSettings.json ,but when running using the exe , all microservices starts from port 5001 .

  "$schema": "http://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false, 
    "anonymousAuthentication": true, 
    "iisExpress": {
      "applicationUrl": "http://localhost:5004",
      "sslPort": 44345
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "api/values",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "myapp": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "api/values",
      "applicationUrl": "http://localhost:5004",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

Kestrel server is configured to run dotnet core app on 5000 and 5001. But you can override it by providing command line argument --urls while executing exe. You can read it more on Setting Up Kestrel

Alternate way to override default port is to run it from cmd. Suppose your exe's name is webapi then to override default port open cmd and go to the folder where exe is located and run
. Port is integer value where kestrel will start listening.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM