ASP.NET读取设置Web.config文件

C#读取web.config文件信息

web.config

<?xml version="1.0"?>
<!--
  有关如何配置 ASP.NET 应用程序的详细信息,请访问
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <appSettings>
    <add key="name" value="name1"/>
  </appSettings>
</configuration>

C#读取

 string name = System.Web.Configuration.WebConfigurationManager.AppSettings["name"];

C#设置

 System.Web.Configuration.WebConfigurationManager.AppSettings.Set("name", "name2");

你可能感兴趣的:(asp.net)