Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How get web config location element?

How get web config location element?

ConfigurationManager.GetSection("appSettings") returns Okay

ConfigurationManager.GetSection("location") return null

I.E. ...

<location path="FOLDER/Page2.aspx">
...
</location>
like image 729
Paulo Barbosa Avatar asked Nov 11 '10 16:11

Paulo Barbosa


1 Answers

Does this help?

Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
ConfigurationLocationCollection myLocationCollection = config.Locations;
foreach (ConfigurationLocation myLocation in myLocationCollection)
{
    Console.WriteLine("Location Path: {0}", myLocation.Path);
    Configuration myLocationConfiguration = myLocation.OpenConfiguration();
    Console.WriteLine("Location Configuration File Path: {0}",              myLocationConfiguration.FilePath);
}
Console.WriteLine("Done...");
Console.ReadLine();

Taken from here

like image 168
Neil Knight Avatar answered Oct 24 '22 05:10

Neil Knight