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

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
 
J

Joshua Flanagan

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top