如何通过 httpcontext 获取对配置管理器的引用?
谢谢
正如亚当所指出的,使用:
System.Configuration.ConfigurationManager
如果它在一个单独的项目中的一个类中并不重要。当您从 Web 项目调用代码时,ConfigurationManager 将逻辑应用到您的 Web 应用程序,而不是包含的项目。
简单地说: System.Configuration.ConfigurationManager.AppSettings[""] (当然,使用 stmt up top for System.Configuration - 并确保您的库具有对 system.configuration 的引用)