因为Orchard的模块的路径位于Orchard.Web\Modules\XXX下,不能通过WebConfigurationManager.AppSettings直接访问,可以通过如下方法:
public class ConfigHelper
{
public static string CurrentAppSettings(string key)
{
return ModuleAppSettings("模块名称", key);
}
private static string ModuleAppSettings(string module, string key)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration(string.Concat("~/Modules/", module));
KeyValueConfigurationCollection appSettings = config.AppSettings.Settings;WebConfigurationManager.AppSettings
return appSettings[key].Value;
}
}