Re: web.config question 2.0



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.






.



Relevant Pages

  • Re: web.config question 2.0
    ... can only retrieve connection strings from within the current application. ... To retrieve configuration settings from a different application, ... What you're proposing would remove the application's configuration as an application, ... Juan T. Llibre, asp.net MVP ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Encrypt connection string - Access denied
    ... Protecting Connection Strings and Other Configuration Information ... The sample code works fine, but it does not work in my web application ... on my local machine or on a test server. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Web.config or App.config Security
    ... Connection Strings and Other Sensitive Settings in Your Code" at ... encryption). ... >> in the application source code, event though these are bad choices as ...
    (microsoft.public.dotnet.security)
  • Re: ActiveDirectoryMembershipProvider "Access is denied."
    ... I should add that we are currently using Windows XP developer web server and ... work so we can use the built in Login Control but we are getting "Access ... passwords and connection strings and get an error saying that it can't ... An error occurred during the processing of a configuration ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Data Access Application Block with C#
    ... And here is the list of connection strings. ... Notice the Data Source of a textfile is the DIRECTORY, ... Find the folder called Tests, and copy the entire Tests folder to the ... OLEDB folder you created ...
    (microsoft.public.dotnet.languages.csharp)