Adding Custom Application Settings

You can easily add custom configuration settings to the web configuration file by taking advantage of the appSettings section, which section contains a list of key and value pairs. For example, the web configuration file in Listing 34.4 contains a welcome message and a copyright notice.

Listing 34.4. Web.config

images

You can retrieve values from the appSettings section either programmatically or declaratively. The page in Listing 34.5 illustrates both approaches (see Figure 34.4).

Figure 34.4. Displaying values from the appSettings configuration section.

Listing 34.5. ShowAppSettings.aspx

In Listing 34.5, the ...

Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.