title: How can I retrieve AppSettings configuration back in Asp.Net MVC 6?
body: <p>Assuming that I am using the new DepencyInjection framework to configure my classes and dependencies in the new ASP.Net/vNext.</p>
  
  <p>How can I use, How can I get my pre-defined configuration settings?</p>
  
  <pre><code>    public void ConfigureServices(IServiceCollection services)
      {
          // Add Application settings to the services container.
          services.Configure&lt;AppSettings&gt;(Configuration.GetSubKey("AppSettings"));
  
          // Add EF services to the services container.
          services.AddEntityFramework()
              .AddSqlServer()
              .AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
                  options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
          // Add Identity services to the services container.
          services.AddIdentity&lt;ApplicationUser, IdentityRole&gt;()
              .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;()
              .AddDefaultTokenProviders();
  
          // Configure the options for the authentication middleware.
          // You can add options for Google, Twitter and other middleware as shown below.
          // For more information see http://go.microsoft.com/fwlink/?LinkID=532715
          services.Configure&lt;FacebookAuthenticationOptions&gt;(options =&gt;
          {
              options.AppId = Configuration["Authentication:Facebook:AppId"];
              options.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
          });
  
          services.Configure&lt;MicrosoftAccountAuthenticationOptions&gt;(options =&gt;
          {
              options.ClientId = Configuration["Authentication:MicrosoftAccount:ClientId"];
              options.ClientSecret = Configuration["Authentication:MicrosoftAccount:ClientSecret"];
          });
  
          // Add MVC services to the services container.
          services.AddMvc();
  
          services.AddSingleton(a =&gt;
          {
              //AppSettings settingsModel = ?? //GET CONFIGURATION SETTINGS FILLED 
  
              // TECHNICAL ARTIFICE TO RETRIEVE CURRENT SETTINGS
              //var settingsModel = new AppSettings();
              //var config = Configuration.GetSubKey("AppSettings");
              //foreach (var item in typeof(AppSettings).GetProperties().Where(b =&gt; b.CanWrite))
              {
                  //item.SetValue(settingsModel, config.Get(item.Name));
              }
  
              return new FooService(settingsModel);
          });
  
          //Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers.
          //You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json.
          services.AddWebApiConventions();
      }
  </code></pre>