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.

image

Listing 34.26. EncryptConfig.aspx

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

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.