ASP.NET's Configuration System

Have you ever wondered how ASP.NET installs its fancy 'Web.config' configuration system?  Well, here it is...

HttpConfigurationSystemBase configSystem = new HttpConfigurationSystem();
MethodInfo method = typeof(ConfigurationSettings).GetMethod("SetConfigurationSystem", BindingFlags.NonPublic);
method.Invoke(null, new object[] {configSystem});

It uses refection to call a private method.  I didn't expect to find that!

Published Wednesday, February 04, 2004 3:45 AM by Jamie Cansdale

Comments

# Bootstrapping ASP.NET's Configuration System

Tuesday, February 03, 2004 10:44 PM by TrackBack

# Bootstrapping ASP.NET's Configuration System

Tuesday, February 03, 2004 10:47 PM by TrackBack

# re: ASP.NET's Configuration System

Nasty little hacks creeping under the hood my precioussss...

Wednesday, February 04, 2004 4:28 AM by Fabrice

# re: ASP.NET's Configuration System

Dude, I've been looking for that code for forever. Where did you find it?

I knew installing the config system had to be dirty based on what the ConfigurationSettings exposes, but I didn't expect anything quite like that. :)

Wednesday, February 04, 2004 8:27 AM by Ben

# re: ASP.NET's Configuration System

Reflector wouldn't want to take the precioussss away from you... :)

Wednesday, February 04, 2004 9:42 AM by Jamie Cansdale

# re: ASP.NET's Configuration System

Right, I get that you can find it with reflector, but *where*? What class / method? You tease me with knowledge!

Wednesday, February 04, 2004 1:01 PM by Ben

# re: ASP.NET's Configuration System

Hah, HttpConfigurationBase.EnsureInit().

I really cannot beleive it's this dirty.

Wednesday, February 04, 2004 1:04 PM by Ben

Leave a Comment

(required) 
(required) 
(optional)
(required)