How config.json found ASP.NET 5

Presumably everything that an ASP.NET 5 website needs to run comes under wwwroot. However, when I look at this directory, when the site is up, I cannot see the config.json. So the question is, how does my website launch code find config.json if it's not under wwwroot?

A related question, if I want to create my own config file (since config.json only handles simple name / value pairs), would I put it next to config.json in my project, or under wwwroot so that I can read the content at runtime?

+3


source to share


1 answer


Which in the wwwroot folder represents everything your site can access from HTTP. You can access your config files at runtime, but you cannot create web requests for them (since they are not in wwwroot).

ASP.NET finds root config.json in Startup class:



public Startup(IHostingEnvironment env)
    {
        // Setup configuration sources.
        var configuration = new Configuration()
            .AddJsonFile("config.json")
            .AddJsonFile($"config.{env.EnvironmentName}.json", optional:   true);

      

+3


source







All Articles