Hi,
I have a web app. I am referencing some code in the web application. For example, when I reference this code>>
con = new SqlConnection(ConfigurationManager.AppSettings["DbConString"].ToString());
It should read the key / value from web.config file ( see code below ).... and not from app.config...
(which is the values of the project properties in settings.settigns)
<appSettings>
<add key="DbConString" value="xxxxxx" />
</appSettings
Is this correct.
and if I want to read the property from app.config, I use this code>>
private string con = BL.Properties.Settings.Defaul.DbConString;
providing the app.config contains .....
<configuration>
<configSections>
<applicationSettings>
<BL.Properties.Settings>
<setting name="DbConString" serializeAs="String">
<value>xxxxxx</value>
</setting>
</BL.Properties.Settings>
</applicationSettings>
</configuration>
I appreciate confirming if the above is correct.
thanks
Bob
Please remember to click “Mark as Answer” on the post that helps you and to unmark it if a marked post does not actually answer your question.
Thank you!
----------------------
"Microsoft Community Contributor Award 2011"
Marked as answer by Dino He - MSFT on Jul 13, 2012 05:29 AM
bobwhite
Member
704 Points
669 Posts
settings.settings vs web.config & how to read the values from web app
Jul 09, 2012 09:18 PM|LINK
<appSettings> <add key="DbConString" value="xxxxxx" /> </appSettings Is this correct. and if I want to read the property from app.config, I use this code>> private string con = BL.Properties.Settings.Defaul.DbConString; providing the app.config contains ..... <configuration> <configSections> <applicationSettings> <BL.Properties.Settings> <setting name="DbConString" serializeAs="String"> <value>xxxxxx</value> </setting> </BL.Properties.Settings> </applicationSettings> </configuration> I appreciate confirming if the above is correct. thanks Bobsanta_1975
Star
8574 Points
1499 Posts
Re: settings.settings vs web.config & how to read the values from web app
Jul 10, 2012 12:19 AM|LINK
Hi,
Refer to this link.
http://www.4guysfromrolla.com/articles/053102-1.aspx
Hope this helps.
Thank you!
----------------------
"Microsoft Community Contributor Award 2011"