AppSettingsExpressionBuilder Class
Retrieves values, as specified in a declarative expression, from the <appSettings> section of the Web.config file.
System.Web.Compilation::ExpressionBuilder
System.Web.Compilation::AppSettingsExpressionBuilder
Assembly: System.Web (in System.Web.dll)
The AppSettingsExpressionBuilder type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | AppSettingsExpressionBuilder | Initializes a new instance of the AppSettingsExpressionBuilder class. |
| Name | Description | |
|---|---|---|
![]() | SupportsEvaluate | Returns a value indicating whether an expression can be evaluated in a page that is not compiled. (Overrides ExpressionBuilder::SupportsEvaluate.) |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | EvaluateExpression | Returns a value from the <appSettings> section of the Web.config file. (Overrides ExpressionBuilder::EvaluateExpression(Object, BoundPropertyEntry, Object, ExpressionBuilderContext).) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() ![]() | GetAppSetting(String) | Returns a value from the <appSettings> section of the Web.config file. |
![]() ![]() | GetAppSetting(String, Type, String) | Returns a value from the <appSettings> section of the Web.config file with the value converted to a target type. |
![]() | GetCodeExpression | Returns a code expression that is used to perform the property assignment in the generated page class. (Overrides ExpressionBuilder::GetCodeExpression(BoundPropertyEntry, Object, ExpressionBuilderContext).) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ParseExpression | When overridden in a derived class, returns an object that represents the parsed expression. (Inherited from ExpressionBuilder.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
The AppSettingsExpressionBuilder class provides access to values in the <appSettings> section of the Web.config file. The <appSettings> section of the Web.config file contains application-specific values in key/value pairs.
An application value is retrieved by assigning an expression of the form
<%$ AppSettings: appSettingsKey %>
to a property in a control declaration. The part of the expression before the colon (:) designates the type of expression to be retrieved, and the part after the colon signifies the key. The preceding expression would retrieve the following value from the Web.config file.
<appSettings>
<add key="appSettingsKey" value="appSettingsValue"/>
</appSettings>
When the page parser encounters an expression with the AppSettings prefix, it creates an instance of the AppSettingsExpressionBuilder class to handle the expression.
If the expression is encountered in a page that will be compiled, the AppSettingsExpressionBuilder object generates code to retrieve the specified value from the Web.config file. This code is executed during the execution of the generated page class. If the expression is encountered in a page that will not be compiled, the AppSettingsExpressionBuilder object returns the value from the Web.config file when the page is parsed and executed.
The following code example demonstrates how to retrieve an application settings value in a page that is not compiled.
This code retrieves the following expression from the Web.config file.
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="thisSeason" value="Fall"/>
</appSettings>
</configuration>
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.



