Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Custom Environments in ASP.NET Core

My appsettings files does work I see them being used according to which launching profile I use however my localhost profile doesn't work because it doesn't seems to exist in the actual Framework I use. Is there anyway to add a custom one such as "localhost"?

My appsettings files does work I see them being used according to which launching profile I use however,,,

My Localhost profile doesn't work because it doesn't seems to exist in the actual Framework I use. Is there anyway to add a custom one such as "localhost"?

Edit :

enter image description here

Thanks!

like image 738
ItsNotMyFault Avatar asked Jun 20 '26 05:06

ItsNotMyFault


1 Answers

In your Program.cs, add a call to config.AddJsonFile():

    public static void Main(string[] args)
    {
        CreateWebHostBuilder(args).Build().Run();
    }

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .ConfigureAppConfiguration((hostingContext, config) =>
            {
                config.AddJsonFile("appsettings.Localhost.json", optional: true);
            })
            .UseStartup<Startup>();
like image 184
Jeffrey Rennie Avatar answered Jun 25 '26 01:06

Jeffrey Rennie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!