2010-09-06 1 views
9

Gibt es eine "nette" Möglichkeit, die Konfigurationsbereichsgruppe von IIS7 mit WebConfigurationManager zu lesen? Ich habe versucht, den Autorisierungsabschnitt zu lesen, aber WebConfigurationManager.GetSection() gibt eine 'IgnoredSection'-Instanz zurück. Dies ist, was mein Code sieht aus wie ...Wie lese ich den system.webserver Konfigurationsabschnitt?

authSection = WebConfigurationManager.GetSection("system.webServer/security/authorization", HttpContext.Current.Request.Path) 

Antwort

5
Configuration webConfig = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); 
ConfigurationSection cs = webConfig.GetSection("system.webServer"); 
if (cs != null) 
{ 
    XDocument xml = XDocument.Load(new StringReader(cs.SectionInformation.GetRawXml())); 
    ... 
} 
+0

wie Custom Werte lesen? Meine web.config ist als unten ABB