使用 ConfigurationManager 从 Web.Config 中读取键。
使用 ConfigurationManager 从 Web.Config 中读取键。
我在一个不同的层次(同一个解决方案)中尝试从Web.config
文件中读取键。
以下是我正在尝试的内容:
string userName = System.Configuration.ConfigurationManager.AppSettings["PFUserName"]; string password = System.Configuration.ConfigurationManager.AppSettings["PFPassWord"];
这是我的Web.config
文件中的appSettings
:
.... ....
当我调试代码时,username
和password
仅为null
,因此未获取密钥的值。
我读取这些值时做错了什么?
admin 更改状态以发布 2023年5月20日