I want my project to start on a particular port using both IIS Express and Kestrel in Visual Studio, using the 'IIS Express' or 'web' start button.
By default, the launchSettings.json file contains a specific port number for IIS Express. However, Kestrel is always started on the default port 5000. How can I get Kestrel to also start on the same port as 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"
},
...
}
I have tried changing the web command in project.json to:
"web": "Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5020"
However, this completely stops the site starting in IIS Express.