我没有意识到:我有一个单独的类库一个web.config和我读的web.config从不同的万维网应用程序appsetting
。我使用VS2010的目标框架3.5
我不知道什么是错在这里,但我得到空当我试图让 ConfigurationManager.AppSettings [STOREID];
私人字符串_storeid = GetStoreId;公共静态字符串GetStoreId{ 得到 { 返回ConfigurationManager.AppSettings [STOREID]; }}Web.confid:
<&的appSettings GT; <添加键=STOREIDVALUE =123/>< /的appSettings>解决方案
是你在上面使用一个单独的类库到您的主asp贴库吗?code
如果你是,你已经添加了一个app.config这个库上方,然后ConfigurationManager中不读取正确的文件,因为这将期待您的asp库中的web.config文件发布的设置。
i did not realize that: i have a web.config in a separate class library and i was reading the web.config appsetting from different web applicaiton.
i am using VS2010 target framework 3.5
i dont know what is wrong here but i am getting null when i try to get ConfigurationManager.AppSettings["StoreId"];
private string _storeid = GetStoreId; public static string GetStoreId { get { return ConfigurationManager.AppSettings["StoreId"]; } }Web.confid:
<appSettings> <add key="StoreId" value="123" /> </appSettings>解决方案
Is the code you posted above using a separate class library to your main asp library?
If you are and you have added an app.config to this library with the settings posted above then the ConfigurationManager is not reading the right file as this will look to the web.config file for your asp library.
更多推荐
ConfigurationManager.AppSettings越来越空?
发布评论