Hi,
I had some trouble on a test server with an ASP.NET website. I goofed, and had the home directory of the Default Web Site pointed to the wrong place. When I tried:
ConfigurationManager.ConnectionStrings["connectionString"];
it returned null, but
System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
rootWebConfig.ConnectionStrings.ConnectionStrings["connectionString"].ConnectionString;`
returned the correct connection string.
What are all the differences between the two approaches?
EDIT: What I'm really asking is, why does the ConfigurationManager approach fail when the home directory is incorrectly set, but succeeds otherwise, and the WebConfigurationManager succeeds regardless of whether the home directory is correctly set? Are there any other differences, such as assumptions about access control?