Raul Marquez
Raul Marquez

Reputation: 1116

.NET Core project not reading launchSettings.json

I have a web app using .NET Core 3.1, everything launches fine:

Now listening on: http://localhost:5000
Now listening on: https://localhost:5001

Only thing is that those ports aren't the ones specified in my launchSettings.json file.

A little back story: Originally both those localhosts were specified in the launchSettings.json file, then I eliminated the 5001 one, and it only started the 5000, which is what I wanted.

All of a sudden the 5001 is back, and no matter what I change in the launchSettings.json file it reverts to both 5000 and 5001, I event deleted the launchSettings.json file and it still listens on the same address/ports, I don't know where it's reading it from.

Just for reference, this is my current launchSettings.json file, it's supposed to be reading from the StudentsWebApp profile:

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

This is how I'm running the web app, just clicking the play button or F5 for the startup project:

enter image description here

Why is it bypassing my launchSettings.json file?

Upvotes: 3

Views: 5711

Answers (1)

Raul Marquez
Raul Marquez

Reputation: 1116

After more searching around I got it to work:

Adding this in Project Properties > Debug Tab > Application arguments

--urls=http://localhost:5000/

enter image description here

This way it reads exactly what address/port you want.

Upvotes: 2

Related Questions