Home > Net >  launchSettings.json file opens wrong URL
launchSettings.json file opens wrong URL

Time:05-26

When I try I couldn't run this project in my computer today but my teammates can run at their own computer. By the way I can run other projects. My launchSettings file like this:

{
 "$schema": "http://json.schemastore.org/launchsettings.json",
 "iisSettings": {
   "windowsAuthentication": false,
   "anonymousAuthentication": true,
   "iisExpress": {
     "applicationUrl": "http://localhost:4321",
     "sslPort": 0
   }
 },
 "profiles": {
   "IIS Express": {
     "commandName": "IISExpress",
     "launchBrowser": true,
     //"launchUrl": "User",
     "launchUrl": "swagger",
     "environmentVariables": {
       "ASPNETCORE_ENVIRONMENT": "Development"
     }
   },
   "Dashboard.WebAPI": {
     "commandName": "Project",
     "launchBrowser": true,
     "launchUrl": "User",
     "applicationUrl": "http://localhost:5000",
     "environmentVariables": {
       "ASPNETCORE_ENVIRONMENT": "Development"
     }
   }
 }
}

But when I run this project my url is opening as "https://localhost:4321/swagger/index.html". I guess this problem is because this url is run as "https" but my applicationUrl is "http".

What could be the cause of this problem?

Edit: My browser:

error

CodePudding user response:

On the Visual Studio toolbar their is a dropdown that allows you to select which profile to run. I suspect you are running the IIS Express profile when you want to run the Dashboard.WebAPI profile. If you see "IIS Express" on your toolbar with a green arrow to the left of it then select the dropdown and choose Dashboard.WebAPI (see mocked up image below)

enter image description here

CodePudding user response:

Either disable Https redirection in your Startup.cs/Program.cs depending whether you use .net5 or .net6 or put your sslPort value in launchSettings.json to a 4322 port (or some other of your choosing, just not any that are in use) and it'll work.

Edit:

{
 "$schema": "http://json.schemastore.org/launchsettings.json",
 "iisSettings": {
   "windowsAuthentication": false,
   "anonymousAuthentication": true,
   "iisExpress": {
     "applicationUrl": "http://localhost:4321","https://localhost:4322",
     "sslPort": 4322
   }
 },
 "profiles": {
   "IIS Express": {
     "commandName": "IISExpress",
     "launchBrowser": true,
     //"launchUrl": "User",
     "launchUrl": "swagger",
     "environmentVariables": {
       "ASPNETCORE_ENVIRONMENT": "Development"
     }
   },
   "Dashboard.WebAPI": {
     "commandName": "Project",
     "launchBrowser": true,
     "launchUrl": "User",
     "applicationUrl": "http://localhost:5000","https://localhost:5001"
     "environmentVariables": {
       "ASPNETCORE_ENVIRONMENT": "Development"
     }
   }
 }
}
  • Related