On an asp.net core 2 web api, I want to be able to set the url on which my api will listen (api run as windows service) based on a value in appsettings.json file. I can't find a way to achive it, how can I have acces to an instance of IConfiguration
?
var pathToExe = Process.GetCurrentProcess().MainModule.FileName;
var pathToContentRoot = Path.GetDirectoryName(pathToExe);
return WebHost.CreateDefaultBuilder(args)
.UseContentRoot(pathToContentRoot)
.UseStartup<Startup>()
.UseUrls({value_from_appsettings})
.Build()
.RunAsService();