locked
How to store and retrieve a string from the web.config file? RRS feed

  • Question

  • User1080700311 posted

     

    Hello I have a connection string in my database which I read throughout my VB .Net application.

    I have another string which is NOT a connection string though. It instead has information about

    a domain on LDAP. So LDAP string just needs to be stored in the web.config as a string, and also to be retrieved as a string.

    LDAP://Lacroix.aet.com"

     How shall I store it in the web.config? And how can I retrieve this value in my VB.net code?

    I know this is different than storing connection strings, but I don't know how to go about it?

     

     

    Friday, May 15, 2009 2:45 PM

Answers

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 15, 2009 2:54 PM
  • User-1319812544 posted

    put it in appsettings :-

    <AppSettings>

    <Add key="KeyName" value="valueName" />

    </AppSettings>

    To retrieve to value use this :

    System.Web.Configuration.WebConfigurationManager.AppSettings("KeyName")

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 15, 2009 2:54 PM
  • User774434067 posted
    You can save the string as an Application Setting
    <AppSettings>
    <Add key="KeyName" value="valueName" />
    </AppSettings>

    and retrieve it in the code as
    String str = ConfigurationManager.AppSettings.Get("KeyName")

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 15, 2009 3:01 PM

All replies

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 15, 2009 2:54 PM
  • User-1319812544 posted

    put it in appsettings :-

    <AppSettings>

    <Add key="KeyName" value="valueName" />

    </AppSettings>

    To retrieve to value use this :

    System.Web.Configuration.WebConfigurationManager.AppSettings("KeyName")

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 15, 2009 2:54 PM
  • User774434067 posted
    You can save the string as an Application Setting
    <AppSettings>
    <Add key="KeyName" value="valueName" />
    </AppSettings>

    and retrieve it in the code as
    String str = ConfigurationManager.AppSettings.Get("KeyName")

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 15, 2009 3:01 PM