/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
samples/snippets/csharp/VS_Snippets_ADO.NET/DataWorks ConnectionStringsWeb.Encrypt/CS/source.cs
36 строк
879 B
Bill Wagner
Update samples (#38401)
27 ноя 2023, 18:05
Не верифицирован
27 ноя 2023, 18:05
0eadf05
Код
Авторство
О чём код?
using System.Configuration; using System.Web.Configuration; static class Program { static void Main() { } // <Snippet1> static void ToggleWebEncrypt() { // Open the Web.config file. Configuration config = WebConfigurationManager. OpenWebConfiguration("~"); // Get the connectionStrings section. var section = config.GetSection("connectionStrings") as ConnectionStringsSection; // Toggle encryption. if (section.SectionInformation.IsProtected) { section.SectionInformation.UnprotectSection(); } else { section.SectionInformation.ProtectSection( "DataProtectionConfigurationProvider"); } // Save changes to the Web.config file. config.Save(); } // </Snippet1> }