• 一般組態
    web.config
    <?xml version="1.0"?>
    <configuration>
      <appSettings file="out.config">
        <add key="in_string" value="IN"/>
      </appSettings>
    </configuration>

    out.config
    <?xml version="1.0" encoding="utf-8"?>
    <appSettings>
      <add key="out_string" value="out" />
    </appSettings>

    讀取組態:
    System.Configuration.ConfigurationManager.AppSettings["in_string"]
    System.Configuration.ConfigurationManager.AppSettings["out_string"]
  • 連線組態

    讀取組態:
    System.Configuration.ConfigurationManager.ConnectionStrings["default"].ConnectionString
    內部
    <?xml version="1.0"?>
    <configuration>
      <connectionStrings
        <add name="default" connectionString="Data Source=localhost;Initial Catalog=Northwind;Integrated Security=True" providerName="System.Data.SqlClient"/>
      </connectionStrings>
    </configuration>

    外部
    <!-- web.config -->
    <?xml version="1.0"?>
    <configuration>
      <connectionStrings configSource="conn.config" />
    </configuration>

    <!-- conn.config -->
    <connectionStrings>
      <add name="default" connectionString ="data=out;uid=;pid=;"/>
    </connectionStrings>

ASP.NET 1.1 是用 System.Configuration.ConfigurationSettings.AppSettings["default"]