ASP.NET 利用Web.config配置数据


 建立配置数据

  修改Web.config文件

  <configuration>

  <appSettings>

  <add key="password" value="cement" />

  <add key="path" value="E:\iclweb\www\data" />

  </appSettings>

  配置数据的形式为key-value pair。上述例子为password和path。

  使用配置数据

  if (Login1.Password == ConfigurationSettings.AppSettings["password"])

  {

  Server.Transfer("Search.aspx");

  }

  使用ConfigurationSettings.AppSettings取出相应key对应的value。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3