Reputation: 2867
We have an API application made in ASP.NET Core, with Visual Studio 2017. We have 4 developers working in this project and sometimes the port of the project changes without any of us do this alteration.
Here is the debug configuration of the application:
Has this ever happened to anyone?
Upvotes: 2
Views: 6576
Reputation: 145
Change the port binding in
.vs/config/applicationhost.config
on the node
configuration/system.applicationHost/sites/site[<name>]/bindings/binding[bindingInformation]
from an value like
<binding protocol="http" bindingInformation="*:5000:*" />
to an value like this
<binding protocol="http" bindingInformation=":5000:" />
Upvotes: 2
Reputation: 2393
You can use UseUrls for that:
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseUrls("http://localhost:5000/")
.Build();
host.Run();
}
}
UPD:
An alternative by passing arguments:
dotnet run --urls http://0.0.0.0:5000
Upvotes: 0
Reputation: 53600
The port may be changing because launchSettings.json
is ignored by source control. This common gitignore file, for example, excludes:
**/Properties/launchSettings.json
Visual Studio 2017 stores ASP.NET Core server settings (for both IIS Express and Kestrel) in this file. If it's ignored by source control, it will be regenerated on each machine with a random port. If you check the file in, every machine will use the same server settings.
Upvotes: 4