AppSettingsExpressionBuilder クラス
アセンブリ: System.Web (system.web.dll 内)


AppSettingsExpressionBuilder クラスは、Web.config ファイルの <appSettings> セクションの値へのアクセスを提供します。Web.config ファイルの <appSettings> セクションには、アプリケーション固有のキー/値ペアが含まれています。
<%$ AppSettings: appSettingsKey %>
の式をコントロール宣言のプロパティに割り当てることによって取得されます。式のコロン (:) の前の部分は取得する式の種類を表し、コロンの後の部分はキーを表します。前述の式は、Web.config ファイルから次の値を取得します。
<appSettings>
<add key="appSettingsKey" value="appSettingsValue"/>
</appSettings>
ページ パーサーは、プレフィックスが AppSettings の式を見つけると、AppSettingsExpressionBuilder クラスのインスタンスを作成して、その式を処理します。
コンパイルされるページにこの式がある場合、AppSettingsExpressionBuilder オブジェクトは指定した値を Web.config ファイルから取得するコードを生成します。このコードは、生成されたページ クラスの実行中に実行されます。コンパイルされないページにこの式がある場合、AppSettingsExpressionBuilder オブジェクトはページの解析および実行時に Web.config ファイルの値を返します。

アプリケーション設定値をコンパイルされないページから取得する方法を次のコード例に示します。
<%@ Page Language="VB" CompilationMode="Never" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html > <head runat="server"> <title>Noncompiled Page</title> </head> <body> <form id="form1" runat="server"> <div> Welcome to the <asp:Literal ID="Literal1" runat=server Text="<%$ AppSettings: thisSeason %>" /> Sale! </div> </form> </body> </html>
<%@ Page Language="C#" CompilationMode="Never" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html > <head runat="server"> <title>Noncompiled Page</title> </head> <body> <form id="form1" runat="server"> <div> Welcome to the <asp:Literal ID="Literal1" runat=server Text="<%$ AppSettings: thisSeason %>" /> Sale! </div> </form> </body> </html>
このコードは、Web.config ファイルから次の式を取得します。
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="thisSeason" value="Fall"/>
</appSettings>
</configuration>


System.Web.Compilation.ExpressionBuilder
System.Web.Compilation.AppSettingsExpressionBuilder


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- AppSettingsExpressionBuilder クラスのページへのリンク