title: How to store custom data in web.config?
body: <p>I have the following method in my apiController:  </p>
  
  <pre><code>public IEnumerable&lt;something&gt; GetData(DataProvider dataProvider)
  {
      return dataProvider.GetData();
  }
  </code></pre>
  
  <p>What I need is to invoke this method from javascript and pass it a parameter of DataProvider derived type. I can handle this by passing string, e.g. "FirstProvider" and than write N number of if's in GetData() method to create an instance of proper type.  </p>
  
  <p>But is there some way that I can write in web.config file something like:  </p>
  
  <pre><code>&lt;DataProviders&gt;
    &lt;type = FirstDataProvider, alias = "FirstProvider"&gt;
    &lt;type = SecondDataProvider, alias = "SecondProvider"&gt;
  &lt;/DataProviders&gt;
  </code></pre>
  
  <p>Change getData method to:  </p>
  
  <pre><code>public IEnumerable&lt;something&gt; GetData(string dataProviderAlias)
  {
                  // get provider type by it's alias from web congfig,
                  // then instantiated and call: 
      return dataProvider.GetData();
  }
  </code></pre>
  
  <p>And then find and instantiate the type by it's alias?</p>
  
  <p><strong>Note</strong>: I accepted the answer below cause it's pointed me in a right direction, but msdn says that <code>IConfigurationSectionHandler</code> is deprecated.<br>
  So I used <code>ConfigurationSection</code>, <code>ConfigurationElementCollection</code>, <code>ConfigurationElement</code> classes instead to build custom config section.</p>