title: How can i get IConfiguration (injection dependency) in controller with .NET6
body: <p>I am trying to get IConfiguration in controller api with .NET6 . Ihave this Program.cs:</p>
  <pre><code>var builder = WebApplication.CreateBuilder(args);
  
  var config = builder.Configuration;
  
  
  // Add services to the container.
  builder.Services.AddControllers();
  // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
  builder.Services.AddEndpointsApiExplorer();
  builder.Services.AddSwaggerGen();
  builder.Services.AddSingleton&lt;IConfiguration&gt;(config);
  
  var app = builder.Build();
  
  // Configure the HTTP request pipeline.
  if (app.Environment.IsDevelopment())
  {
      app.UseSwagger();
      app.UseSwaggerUI();
  }
  
  
  app.UseHttpsRedirection();
  
  app.UseAuthorization();
  
  app.MapControllers();
  
  
  app.Run();
  </code></pre>
  <p>And i have this controller:</p>
  <pre><code>[Route(&quot;api/[controller]&quot;)]
      [ApiController]
      public class PeriodsController : ControllerBase
      {
          IConfiguration conf;
          PeriodsController(IConfiguration _conf)
          {
              conf = _conf;
          }
          // GET: api/Periods
          [HttpGet]
          public IEnumerable&lt;string&gt; Get()
          {
              return new string[] { &quot;value1&quot;, &quot;value2&quot; };
          }
  }
  </code></pre>
  <p>That does not work. How can i get IConfiguration using injection dependency??</p>
  <p>I receive this error:</p>
  <blockquote>
  <p>A suitable constructor for type 'xxxx.Controllers.PeriodsController' could not be located. Ensure the type is concrete and all parameters of a public constructor are either registered as services or passed as arguments</p>
  </blockquote>