To access values from appsettings.json in an ASP.NET Core application, you can use the IConfiguration interface.

Here's an example of how you can access the values from appsettings.json in a static class:

  1. In your static class, add a property of type IConfiguration and a static constructor to initialize the configuration:
    public static class MyStaticClass
    {
        public static IConfiguration Configuration { get; }
    
        static MyStaticClass()
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
    
            Configuration = builder.Build();
        }
    
        // Add your static methods or properties here
    }
    
  2. Now, you can access the configuration values in your static class using the Configuration property. For example:
    public static class MyStaticClass
    {
        public static IConfiguration Configuration { get; }
    
        static MyStaticClass()
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
    
            Configuration = builder.Build();
        }
    
        public static string GetSomeValue()
        {
            return Configuration["SomeKey"];
        }
    }
    

In the above example, SomeKey is the key in appsettings.json that corresponds to the value you want to retrieve.

Make sure that your appsettings.json file is located in the root directory of your project and has the correct structure.

Note: Static classes can have limitations in terms of testability and dependency injection. It's generally recommended to use dependency injection to inject the IConfiguration into the classes where you need it, rather than relying on a static class.