ASP.Net core lets you run a web server for your web application from the command line with the command:
But there is no command argument passing the port to listen on. For example in Ruby on Rails you could specify the port with the –port (-p) argument:
rails server --port 2000
Instead, ASP.Net Core uses the environment variable ASPNETCORE_URLS to take a string representation of the port and hostname of the server. If you want to change the port that the server listens on at the command line you will need to set the environment variable. Which you can do within the scope of the command:
It would be nice if ASP.NET Core supported this in a similar way to rails but it seems the team has taken a different approach to configuration – relying on environment variables. It’s the same if you need to specify the environment too.