Created
April 2, 2018 15:56
-
-
Save configureappio/5ca8343417d37c1cd5ef7987a1b521c2 to your computer and use it in GitHub Desktop.
Example of using a PhysicalFileProvider to access a JSON file outside of the web site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
BuildWebHost(args).Run(); | |
} | |
public static IWebHost BuildWebHost(string[] args) | |
{ | |
var webhost = WebHost.CreateDefaultBuilder(args); | |
// In the real world you could use this to map to a file outside of source control | |
webhost.ConfigureAppConfiguration(c => { c.AddJsonFile(new PhysicalFileProvider(@"C:\"), @"mysecrets.json", true, true); }); | |
return webhost.UseStartup<Startup>().Build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment