Web applications often need to store security-sensitive data, such as database connection strings and service account credentials in application configuration files. For security reasons, this type of information should never is stored in plain text and should always be encrypted prior to storage.
This How To describes how to use DPAPI from ASP.NET. This includes ASP.NET Web applications, Web services, and .NET Remoting components that are hosted in ASP.NET.
The code in this How To references DPAPI through a managed class library, the creation of which is described in “How To: Create a DPAPI Library” in the Reference section of this book.