我希望我的项目在Visual Studio中使用IIS Express和Kestrel,使用“IIS Express”或“web”开始按钮在特定端口上启动。
默认情况下,launchSettings.json文件包含IIS Express的特定端口号。但是,Kestrel始终在默认端口5000上启动。如何让Kestrel也能在与IIS Express相同的端口上启动?
{
"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"
}
}
}
}
{
...
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
...
}
我尝试将project.json中的web命令更改为:
"web": "Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5020"
然而,这完全阻止了从IIS Express开始的站点。