title: Getting Dot.Net Core AppSettings in a Class, and I'm not using MVC
body: <p>Lots of answers to this question, if you're using MVC, but what if you're not using MVC?  I have a class of <strong>Student</strong>, and it has all the Crud in it.  I can't use any of the examples because of the call to the class. I'm new to Core but have been using Web Forms and MVC for some time. </p>
  
  <p>When I make a call as shown for an example:</p>
  
  <pre><code>Student s = new Student();
  s.FullName = "Sam";
  s.Update;
  </code></pre>
  
  <p>I get the error that IConfiguration or IOptions is needed, depending on how I'm trying to call the AppSettings. </p>
  
  <p>Startup.cs</p>
  
  <pre><code>   IConfigurationSection appSetting = Configuration.GetSection("AppSettings");
     services.Configure&lt;AppSettings&gt;(appSetting);
  </code></pre>
  
  <p>Student Class</p>
  
  <pre><code>   public class Student
       {
           private readonly IOptions&lt;AppSettings&gt; _appSetting;
  
                public Student(IOptions&lt;AppSettings&gt; appSettings)
                {
                     _appSetting = appSettings;
                }
  </code></pre>
  
  <p>Where it's called in the Student class</p>
  
  <pre><code>public Student GetStudent(Guid StudentGUid)
        {
             var Conn = _appSetting.Value.ApplicationConn;
  
             using (IDbConnection con = new SqlConnection(Conn))
             {
  </code></pre>
  
  <p>Where I call class on page .cs</p>
  
  <pre><code>      Student sa = new Student();
        sa.GetStudent(new Guid("2b583b82-0337-425b-ac73-3830bc20253f"));
        var s = sa.LastName;
  </code></pre>
  
  <p>The error:</p>
  
  <p>*There is no argument given that corresponds to the required formal parameter'appSetting .... , which makes sense. But this is where I go off the rails, as I can't just put in the IOption value because it always comes out null.  </p>
  
  <p>AppSettings Class</p>
  
  <pre><code>public class AppSettings
       {
            public string ApplicationID { get; set; }
            public string ApplicationUrl { get; set; }
            public string ApplicationConn { get; set; }
       }
  </code></pre>
  
  <p>JSON File</p>
  
  <pre><code> "Logging": {
        "LogLevel": {
             "Default": "Information",
             "Microsoft": "Warning",
             "Microsoft.Hosting.Lifetime": "Information"
        }
   },
   "AppSettings": {
        "ApplicationID": "Some Guid",
        "ApplicationUrl": "xxxxxx",
        "ApplicationConn": "Connection String"
   },
   "AllowedHosts": "*"
  </code></pre>