Update:
I have just come across the Environment variables which seem a FAR better place to set this, also this is how I would have done it in VS 2017.
In JetBrains Rider they are under the build configs (Run dropdown then Edit Configurations...).
![Run - Edit Configurations]()
Under this window you can edit your build configurations. Find the one you use (I only have one currently but you might have a dev, staging etc...) and then find the Environment variables: (green) and click the button on the right (blue).
![Run/Debug Configurations]()
In the new window you can change the ASPNETCORE_URLS to what ever you require. For me I set it to http://*:5000 which causes it to pick up any incoming requests. For example localhost:5000 or 192.168.0.10:5000. I then pointed my dev.somedomain.com to 192.168.0.10:5000 and I can use https though NGINX to test on my dev site running on my Mac.
![enter image description here]()
This also allows for easily changing it on a PC my PC basis by not checking in the JetBrains Rider settings.
Original Answer:
I have finally found the answer to this and @Métoule was right in the comment. I just didn't understand what it meant until now.
Basically the changes in the Program.cs in ASP.NET CORE 2.0 is just a way to hide away the stuff that will always be the same.
Instead of calling all these (like you needed to in Core 1):
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights()
.Build();
You're just calling the ones you're likely to want to change:
.UseStartup<Startup>()
.Build();
SO you can still add UseUrls() as before just put it before the .Build();` like this:
.UseStartup<Startup>()
.UseUrls("http://192.168.2.10:5000")
.Build();
SO to change the Url of a brand new ASP.NET CORE 2 project I changed the Program class in the Program.cs file from:
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
To:
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseUrls("http://192.168.2.22:5000")
.Build();
}
Only adding the 3rd from last line: .UseUrls("http://192.168.2.22:5000")
As long as there are no firewalls in the way I can now access the above url from another machine on the network and see my dev site! :D