I am doing the following in my asp.net core 1.0 web api (.NET Framework) program.cs to specify which port I want my web api exe to run in for development purposes only:
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseUrls(new string[1] { "http://*:12012" })
.Build();
host.Run();
}
However, when I publish to production this line causes the WebAPI to error since I want the exe to use the production web-api url i.e. productionWeb/api/values rather than localhost:12012/values
Is there anyway I can get the best of both worlds being able to specify that I want it to run on port 12012 for development purposes and the production url for prod purposes?
My current solution is to just comment out the line before publishing.