Encrypting Sections Programmatically

Instead of using the aspnet_regiis tool to encrypt configuration sections, you can use the Configuration API. Specifically, you can encrypt a configuration section by calling the SectionInformation.ProtectSection() method.

For example, the ASP.NET page in Listing 34.26 displays all the sections contained in the system.web section group in a GridView control. You can click Protect to encrypt a section and UnProtect to decrypt a section (see Figure 34.14).

Figure 34.14. Encrypting and decrypting configuration sections.


Listing 34.26. EncryptConfig.aspx

When you click the Protect link, the grdSection_RowCommand() ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.