So I've finally got round to looking at Core and I've fallen at the first hurdle. I'm following the Pluralsight ASP.NET Core Fundamentals course and I'm getting an exception when trying too add the appsettings.json file to the configuration builder.
public Startup()
{
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json");
Configuration = builder.Build();
}
The error I'm getting is The configuration file 'appsettings.json' was not found and is not optional. But I have created the directly under my solution just like in the course video.
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json");
Configuration = builder.Build();
}
This seems to do the trick. However unsure this is the proper way to do it. Kinda feels like a hack.