Re: web.config question 2.0



Good point. Agreed.
:-)
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder(BETA): http://www.blogmetafinder.com



"Juan T. Llibre" wrote:

I should have added, Peter, that System.Configuration.ConfigurationManager
can only retrieve connection strings from within the current application.

To retrieve configuration settings from a different application, you need :
WebConfigurationManager.OpenWebConfiguration.

What you're proposing would remove the application's configuration as an application,
which might be troublesome for some application properties, if they're configured in the root application.

See my replies to Mark, in this same thread, for more explanatory concepts...and sample code.

The bottom-line answer is : always use the *current* application's
web.config to store/retrieve connection strings.




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Peter Bromberg [C# MVP]" <pbromberg@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E8D2E8E3-D8E6-4F7D-B0C0-835F76269F35@xxxxxxxxxxxxxxxx
The problem you may have here is that if the folder containing your
web.config is marked as an application in IIS, that's the web.config that
takes precedence for this folder. If you were to undo the application here,
remove the web.config, and ensure that all the required items are in the one
in the parent folder, then it may work.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder(BETA): http://www.blogmetafinder.com



"eagle" wrote:

I have a web.config in my application that contains the connection strings
to all my datasources. I want to move these connection strings to another
web config up the folder hierarchy so that all my apps can use the same
connection strings. That is supposed to be how it's done, no? Instead of
the web.config being in c:\inetpub\wwwroot\myApp\web.config, I have it in
c:\inetpub\wwwroot\web.config. However, I get an "Object reference not set
to an instance of an object" error when I do this. This used to work fine
in Visual Studio 2003 .net 1.0.

My connection string is fine:

<connectionStrings>
<add name="myDB" connectionString="Data Source=mySvr;Initial
Catalog=myDB;Integrated Security=True "/>
</connectionStrings>

And this is how I retrieve in in the web app:

_sSQLConn =
System.Configuration.ConfigurationManager.ConnectionStrings("myDB").ToString

What am I doing wrong?

Thanks for your help.







.