使用 ConfigurationManager 从 Web.Config 中读取键。

11 浏览
0 Comments

使用 ConfigurationManager 从 Web.Config 中读取键。

我在一个不同的层次(同一个解决方案)中尝试从Web.config文件中读取键。

以下是我正在尝试的内容:

string userName = System.Configuration.ConfigurationManager.AppSettings["PFUserName"];
string password = System.Configuration.ConfigurationManager.AppSettings["PFPassWord"];

这是我的Web.config文件中的appSettings

   ....
   
      
      
   
   ....

当我调试代码时,usernamepassword仅为null,因此未获取密钥的值。

我读取这些值时做错了什么?

admin 更改状态以发布 2023年5月20日
0
0 Comments
  var url = ConfigurationManager.AppSettings["ServiceProviderUrl"];

,中文意思是“123”。

0
0 Comments

试着使用来自 System.Web.Configuration 命名空间的 WebConfigurationManager 类。例如:

string userName = WebConfigurationManager.AppSettings["PFUserName"]

0