I have an Asp.Net Core 2.2 application using Kestrel with default settings. I went in the project's debug properties and set the "Launch Browser" setting to the page I want to start with when debugging and "Launch" to "Project". This all works fine but I want Kestrel to use a specific port. I found plenty of example that work for the port (I use the hosting.json way) but all of them seem to disregard the "Launch Browser" setting.
Is there no way to have Visual Studio automatically open a new window/tab with my chosen URL and use a specific port when I debug?
Program.cs
public class Program
{
public static void Main(string[] args)
{
var host = WebHost.CreateDefaultBuilder(args)
.UseKestrel()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
launchSettings.json
{
"profiles": {
"Kestrel": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger"
}
}
}
hosting.json
{
"urls": "https://localhost:44350/;"
}
and if I'm using hosting.json, my main is:
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddCommandLine(args)
.AddJsonFile("hosting.json", optional: true)
.Build();
var host = WebHost.CreateDefaultBuilder(args)
.UseConfiguration(config)
.UseKestrel()
.UseStartup<Startup>()
.Build();
host.Run();
}