我需要在我的 Web 应用程序中获取当前配置的实例。我发现我可以通过以下方式获取:
Configuration configuration = WebConfigurationManager.OpenWebConfiguration( HttpContext.Current.Request.ApplicationPath);
但是在我项目的某些部分我没有HttpContext 所以我需要在不使用HttpContext 的情况下获取配置实例。
最佳答案
你是对的 Lubochkn ~ 成功了......
_webConfigurationManager = WebConfigurationManager.OpenWebConfiguration("~");
关于c# - 如何在不使用 HttpContext 的情况下获取 Web 应用程序的当前配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8052677/