ASP.NET核心:如何更改IIS Express端口?

时间:2021-12-11 03:34:03

I'm using IIS Express to host my website and API both of which are ASP.NET Core apps. When I look at my HTTP network logs using Fiddler, I always forget what port belongs to which app. To solve this, I would like to change the port number that my apps currently use to a number that is more memorable.

我正在使用IIS Express来托管我的网站和API,这两者都是ASP.NET核心应用程序。当我使用Fiddler查看我的HTTP网络日志时,我总是忘记哪个端口属于哪个应用程序。为了解决这个问题,我想将我的应用当前使用的端口号更改为更难忘的数字。

For example, I want my UI website to use port 50000 and my internal API to use 50001.

例如,我希望我的UI网站使用端口50000和我的内部API来使用50001。

Intuition tells me to change the "sslPort" and "launchUrl" to 50000 and 50001 respectively but that doesn't work.

Intuition告诉我将“sslPort”和“launchUrl”分别更改为50000和50001,但这不起作用。

For example, this is my current launchSettings.json file for my ASP.NET

例如,这是我当前的ASP.NET的launchSettings.json文件

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iis": {
      "applicationUrl": "http://localhost",
      "sslPort": 0
    },
    "iisExpress": {
      "applicationUrl": "http://localhost:29751",
      "sslPort": 44371
    }
  },
  "profiles": {
    "Development": {
      "commandName": "IISExpress",
      "launchUrl": "https://localhost:44371/"
    }
  }
} 

Changing it to this doesn't work

将其更改为此不起作用

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iis": {
      "applicationUrl": "http://localhost",
      "sslPort": 0
    },
    "iisExpress": {
      "applicationUrl": "http://localhost:29751",
      "sslPort": 50000
    }
  },
  "profiles": {
    "Development": {
      "commandName": "IISExpress",
      "launchUrl": "https://localhost:50000/"
    }
  }
} 

Question: Why doesn't this change work? How do I change the port number?

问题:为什么这种改变不起作用?如何更改端口号?

Many thanks...

非常感谢...

1 个解决方案

#1


0  

I found the solution. When changing the SSL port number, it must be within 44300 - 44399 otherwise it won't work. Reference: developercommunity.visualstudio.com/comments/43139/view.html. @Tseng, please remove the "duplicate" flag

我找到了解决方案。更改SSL端口号时,它必须在44300 - 44399之内,否则将无法工作。参考:developercommunity.visualstudio.com/comments/43139/view.html。 @Tseng,请删除“重复”标志

#1


0  

I found the solution. When changing the SSL port number, it must be within 44300 - 44399 otherwise it won't work. Reference: developercommunity.visualstudio.com/comments/43139/view.html. @Tseng, please remove the "duplicate" flag

我找到了解决方案。更改SSL端口号时,它必须在44300 - 44399之内,否则将无法工作。参考:developercommunity.visualstudio.com/comments/43139/view.html。 @Tseng,请删除“重复”标志