reading from the web.config instead of app.config

Last post 06-12-2007 4:16 PM by dbland07666. 2 replies.

Sort Posts:

  • reading from the web.config instead of app.config

    06-12-2007, 9:57 AM
    • Loading...
    • slyttle
    • Joined on 04-11-2007, 2:16 AM
    • Posts 19

    I am referencing a class library from my web application.  The class library has an app.config file and the web application, of course, has it's own web.config.

    For some reason, when the class library executes the statement "ConfigurationSettings.AppSettings[<key>] ", it appears to be reading from the web.config rather than the app.config.

    Has anyone else encountered this and found a solution? (other than putting all my config items into the web.config)

    -Sheldon

  • Re: reading from the web.config instead of app.config

    06-12-2007, 10:47 AM
    Answer

    Configuration.AppSettings[<key>] reads the values form the "AppSettings" of your Web.Config file.

    You could either have all your setting in Web.Config or have external files (with settings like connectionstrings, web service policies, etc) linked/referenced from web.config file.

     http://weblogs.asp.net/pwilson/archive/2003/04/09/5261.aspx

    and http://www.dotnetbips.com/articles/8f57f552-5206-4c08-a1be-aab20c27f5ef.aspx

     

    Filed under:
  • Re: reading from the web.config instead of app.config

    06-12-2007, 4:16 PM
    Answer
    • Loading...
    • dbland07666
    • Joined on 05-15-2007, 10:02 AM
    • Wall Street
    • Posts 697

    The reason this is happening is because in as asp.net app the only application config file is web.config.  When you call that other class library the dll's get copied to your local bin directory and are part of the web app -- that other app doesn't really exist, as far as they are concerned.

    - David

    Please click "Mark as Answer" on all posts that help you.
Page 1 of 1 (3 items)
Microsoft Communities
Page view counter