accessing web.config, basic question....!

Posts   
 
    
Posts: 34
Joined: 03-Oct-2005
# Posted on: 17-May-2006 11:21:02   

Hi All

Not particularly LLBLGen based, but I am using it in the project...

I am fairly new to web development, and am slowly getting to grips with ASP.NET 2. I have created a web application project with a web.config, which all works fine.

My Web app also references a project that is a provider for an ObjectDataSource, and in this I need to instanciate a data access adapter to retrieve the data. This project is not in a subdirectory of the web app, but at the same level as it.

I want to read the value of the connection string from the <connectionStrings> section of the file rather than the <app.settings> to avoid having to duplicate it

but using

        Dim config As Configuration = WebConfigurationManager.OpenWebConfiguration(Nothing)
        Dim ConnectionStringSection As ConnectionStringsSection = config.ConnectionStrings
        ConnectionString = ConnectionStringSection.ConnectionStrings.Item("brooks").ConnectionString

in the constuctor of my data provider opens the default machine.config file rather than the web.config file of my web application.

What am I missing here ?

TIA

Matt

Posts: 34
Joined: 03-Oct-2005
# Posted on: 17-May-2006 11:25:02   

Typical, struggle with it for a day, ask the question, google once again, and find the answer in 15 seconds....

I needed to pass "/" as the path to the open method...