在project.json和launchSettings.json中设置端口

时间:2016-04-20 09:33:24

标签: asp.net asp.net-core asp.net-core-mvc iis-express kestrel-http-server

我希望我的项目在Visual Studio中使用IIS Express和Kestrel,使用“IIS Express”或“web”开始按钮在特定端口上启动。

默认情况下,launchSettings.json文件包含IIS Express的特定端口号。但是,Kestrel始终在默认端口5000上启动。如何让Kestrel也能在与IIS Express相同的端口上启动?

launchSettings.json

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:5020/",
      "sslPort": 44320
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "Hosting:Environment": "Development"
      }
    },
    "web": {
      "commandName": "web",
      "environmentVariables": {
        "Hosting:Environment": "Development"
      }
    }
  }
}

project.json Extract

{
    ...
    "commands": {
        "web": "Microsoft.AspNet.Server.Kestrel"
    },
    ...
}

我尝试将project.json中的web命令更改为:

"web": "Microsoft.AspNet.Server.Kestrel  --server.urls http://localhost:5020"

然而,这完全阻止了从IIS Express开始的站点。

0 个答案:

没有答案