I have a Wep Api project with .net core 3.1 created in VS 2019. For testing I deploy it to a local directory and started the exe from the doployed folder. See Deploy an app to a local folder using Visual Studio. Thats works fine, but the api listen always on the port 5000/50001
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Now listening on: https://localhost:5001
Where to change the port? Settings in Properties/launchSettings.json of the project seems to have no affect (used only for debugging from VS)?
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5101",
"sslPort": 5101
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"commandLineArgs": "Authority=http://localhost:5100",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Api": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5101;http://localhost:5101"
}
}
}
to a local directory and started the exe from the dopleyed folder:
That's because you're starting a Kestrel server and by default it use 5000/5001. Usually, instead call it depoly, we use the term publish. Deploy means deploy it to some server and interact with IIS/nginx. While publish means generate the executable files.
If you want to change the port, you can change the appsettings.{env}.json, add a urls as below:
{
"urls": "http://localhost:8800",
...
Or if you want to override 8800 dynamically, just pass an argument of --urls by:
yourapp.exe --urls=https://localhost:8822
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With