How to read standard (i.e. non-custom) Web.Config settings

  • Thread starter Thread starter Mark Friedman
  • Start date Start date
M

Mark Friedman

I've seen lots of documentation on how to create and read custom
configuration settings but I'm interested in reading a standard setting
(i.e. the loginUrl attribute of the authentication/forms setting). Do I
have to resort to using straight XML reading or is there some other way to
access standard config settings?

Thanks in advance.

-Mark
 
I haven't tried this, but in theory it should work.

1) Look in <configSections> portion of machine.config to find out which
section handler is used to parse the settings you are interested in.
(probably System.Web.Configuration.AuthenticationConfigHandler in your
example)

2) Figure out what data type is returned by that section handler (probably
available from the documentation).

3) Call System.Configuration.ConfigurationSettings.GetConfig() on the
section you are interested in, and cast the result to the data type you
found in step 2

4) Read the properties of the returned object to get the settings.
 
Back
Top