简体   繁体   中英

Different URLs used despite having same launchSettings.json in local enironment

I have an API website. Here is my launchSettings.json .

{
  "$schema": "https://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:40682",
      "sslPort": 44360
    }
  },
  "profiles": {
    "TTRailtrax": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "https://localhost:7184;http://localhost:5184",
      "dotnetRunMessages": true
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

When I run this project, the URL used is https://localhost:44360 .

But when I check out my code on a different computer and run the project, the URL is https://localhost:7184 .

I the URL to be the same on all computers because this API is called from another website in the solution.

I can see the second URL is coming from the TTRailtrax profile, but I don't really understand what these profiles are, or why different computers seems to be choosing different ones. I have confirmed launchSettings.json is checked into source control and is the same on both computers.

Update

Here's what I've learned so far. The two profiles are created by default. One of them ( TTRailtrax ) will use the Kestral server. The other ( IIS Express ) will use IIS Express. I'm not sure why there are two servers or what are the considerations when choosing between them.

Microsoft's documentation shows a dropdown where you can select which profile is being used. I cannot find this anywhere on my system (Visual Studio 2022).

If I go into the project's settings and open the debug launch profiles UI, I can edit the App URL field. However, the App SSL URL field is disabled. (I am using SSL.)

I have not figured out why one of my computers is selecting one profile while the other computer selected the other profile.

The IIS Express profile is for developers who plan to host their app on IIS and want to emulate that environment locally as close as possible. The Kestrel profile is for those who don't want the IIS Express profile - because they do not plan to host using IIS, for example, or because they want their debugging experience to be quicker.

VS remembers which profile you last used to launch the app, so the fact that the version on one machine uses the Kestrel profile suggests that you must have selected that profile at some stage previously. Perhaps this selection was not a deliberate choice on your part.

The dropdown is included as part of the Run button. You have two green arrows, one of them solid and the other outlined. The name of a selected launch profile appears next to the solid green arrow.

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