Web.config and Config.HasFile
I have an hierarchy of web.config files:
1. ..\WebSites\web.config
2. ..\WebSites\mySubfolder\web.config
My starting web page is in mySubfolder.
I do not have IIS installed.
I am working with development server supplied with VisualStudio 2005 .
ASP.NET version is 2.0
In the <script runat="server> section of my web page I have
Page_Load(...)
{
..............
Configuration webConfig =
WebbConfigurationManager.OpenWebConfiguration("~/web.config");
bool hasFile = webConfig.HasFile;
string filePath = webConfig.FilePath;
ConfigurationSectionCollection sectCollection = webConfig.Sections;
ConfigurationSection csSection = sectCollection["connectionStrings"];
ConfigurationSection locSection = sectCollection["location"];
........................
}
When I debug my code, I see that the webConfig.HasFile returnds false, and webConfig.FilePath is empty ("").
Because of it locSection is null (both web.config have <location allowOverride=false> sections. The Configuration section is OK (it is outside the <location> stuff.)
I tried deleting the "allowOverride" to no avail.
I tried to run MS example code from ConfigurationSectionCollection Help; it does not work either.
Why does HasFile returns false?
What the hierarchy of web.config files should be to return HasFile=true?
How access the config sections inside the <location>?
Thank you
geoyar

