title: Is services.AddSingleton<IConfiguration> really needed in .net core 2 API
body: <p>I accessed appsettings.json In .NET Core 2 Web API Controller simply by adding below:</p>
  
  <pre><code>public class MyController : Controller
      {
          private readonly IConfiguration appConfig;
  
          public MyController(IConfiguration configuration)
          {
              appConfig = configuration;
          }
      }
  </code></pre>
  
  <p>Without adding below in Startup class <em>ConfigureServices(IServiceCollection services)</em> after services.AddMvc();:</p>
  
  <pre><code>services.AddSingleton&lt;IConfiguration&gt;(Configuration);
  </code></pre>
  
  <p>Is there any flaws in my approach? In official docs for .Net Core 2 configuration section, its not mentioned to use 'AddSingleton' not even once: <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration" rel="noreferrer">https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration</a></p>
  
  <p>also by searching I couldn't find related content with accessing configuration!
  <a href="https://docs.microsoft.com/en-us/search/index?search=AddSingleton&amp;scope=ASP.NET+Core" rel="noreferrer">https://docs.microsoft.com/en-us/search/index?search=AddSingleton&amp;scope=ASP.NET+Core</a></p>
  
  <p>Links below shows <em>AddSingleton as if mandatory step</em>:</p>
  
  <p><a href="https://stackoverflow.com/questions/38359219/access-appsettings-json-values-in-controller-classes">Access appsettings.json values in controller classes</a></p>
  
  <p><a href="https://blogs.technet.microsoft.com/dariuszporowski/tip-of-the-week-how-to-access-configuration-from-controller-in-asp-net-core-2-0/" rel="noreferrer">https://blogs.technet.microsoft.com/dariuszporowski/tip-of-the-week-how-to-access-configuration-from-controller-in-asp-net-core-2-0/</a></p>