Access web.config from separate Class Library?

前端 未结 6 1361
轻奢々
轻奢々 2020-12-16 15:01

I\'m looking for a good way to achieve the following:

I have a web application (MVC 3), with a separate Class Library that contains the back-end logic of a CMS that

6条回答
  •  暖寄归人
    2020-12-16 16:02

    You can use the ConfigurationManager class to access items in your web.config or app.config file. However, in your class library, be sure to take in the key name of any appSettings and/or connectionString settings from the consumer (preferably in the constructor). This avoids the problem of you choosing a key name that the consumer is already using elsewhere.

提交回复
热议问题