Adding/Retrieving Custom Configuration Settings

Often, you’ll need to store information into the configuration file that is not part of the standard sections. There are two places you can store information in the web.config file. One is in the <appSettings> section. The other is in your own custom section.

Adding and Reading <appSettings>

You can add custom entries to the web.config file. In fact, there’s a section specifically for customized application settings. This section is <appSettings>, and it occurs outside of the <system.web> section. A typical entry in this section is a connection string to a database. The following shows how this might appear in the <appSettings> section:

 <configuration> <appSettings> <add key="ConnectionString" ...

Get Delphi for .NET Developer’s Guide 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.