ConfigurationManager.AppSettings越来越空?

编程入门 行业动态 更新时间:2024-10-24 11:20:35
本文介绍了ConfigurationManager.AppSettings越来越空?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我没有意识到:我有一个单独的类库一个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越来越空?

本文发布于:2023-10-31 06:32:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545297.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ConfigurationManager   AppSettings

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!