<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=ASP.NET_Tutorial%2FConfiguration%2FEncrypt</id>
		<title>ASP.NET Tutorial/Configuration/Encrypt - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=ASP.NET_Tutorial%2FConfiguration%2FEncrypt"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=ASP.NET_Tutorial/Configuration/Encrypt&amp;action=history"/>
		<updated>2026-04-29T14:55:33Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=ASP.NET_Tutorial/Configuration/Encrypt&amp;diff=2833&amp;oldid=prev</id>
		<title> в 15:30, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=ASP.NET_Tutorial/Configuration/Encrypt&amp;diff=2833&amp;oldid=prev"/>
				<updated>2010-05-26T15:30:57Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:30, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=ASP.NET_Tutorial/Configuration/Encrypt&amp;diff=2834&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=ASP.NET_Tutorial/Configuration/Encrypt&amp;diff=2834&amp;oldid=prev"/>
				<updated>2010-05-26T11:57:14Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Decrypt a configuration section by specifying a virtual directory.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
The following command uses the -pd option with the -app option:&lt;br /&gt;
aspnet_regiis -pd connectionStrings -app /MyApp&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
== decrypt a configuration section by using the -pdf option.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
The following command decrypts a configuration file located in a folder named MyWebApp:&lt;br /&gt;
aspnet_regiis -pdf connectionStrings c:\Websites\MyWebApp&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
== Encrypt Config==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;%@ Page Language=&amp;quot;C#&amp;quot; AutoEventWireup=&amp;quot;true&amp;quot; CodeFile=&amp;quot;Default.aspx.cs&amp;quot; Inherits=&amp;quot;EncryptConfig&amp;quot; %&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html PUBLIC &amp;quot;-//W3C//DTD XHTML 1.1//EN&amp;quot; &amp;quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;html xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; &amp;gt;&lt;br /&gt;
&amp;lt;head runat=&amp;quot;server&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;Untitled Page&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;form id=&amp;quot;form1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
File: Default.aspx.cs&lt;br /&gt;
using System;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Configuration;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.Web;&lt;br /&gt;
using System.Web.Security;&lt;br /&gt;
using System.Web.UI;&lt;br /&gt;
using System.Web.UI.WebControls;&lt;br /&gt;
using System.Web.UI.WebControls.WebParts;&lt;br /&gt;
using System.Web.UI.HtmlControls;&lt;br /&gt;
using System.Web.Configuration;&lt;br /&gt;
public partial class EncryptConfig : System.Web.UI.Page&lt;br /&gt;
{&lt;br /&gt;
  protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;
  {&lt;br /&gt;
    Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);&lt;br /&gt;
    ConfigurationSection appSettings = config.GetSection(&amp;quot;appSettings&amp;quot;);&lt;br /&gt;
    if (appSettings.SectionInformation.IsProtected)&lt;br /&gt;
    {&lt;br /&gt;
      appSettings.SectionInformation.UnprotectSection();&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
      appSettings.SectionInformation.ProtectSection(&amp;quot;DataProtectionConfigurationProvider&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    config.Save();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
== Encrypt connectionStrings section with the DataProtectionConfigurationProvider==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
aspnet_regiis -pe connectionStrings -app /MyApp -prov ProtectedConfigurationProvider&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
== Encrypting Sections Programmatically==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;%@ Page Language=&amp;quot;C#&amp;quot; %&amp;gt;&lt;br /&gt;
&amp;lt;%@ Import Namespace=&amp;quot;System.Web.Configuration&amp;quot; %&amp;gt;&lt;br /&gt;
&amp;lt;%@ Import Namespace=&amp;quot;System.Collections.Generic&amp;quot; %&amp;gt;&amp;lt;!DOCTYPE html PUBLIC &amp;quot;-//W3C//DTD XHTML 1.0 Transitional//EN&amp;quot;&lt;br /&gt;
&amp;quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script runat=&amp;quot;server&amp;quot;&amp;gt;&lt;br /&gt;
    void Page_Load()&lt;br /&gt;
    {&lt;br /&gt;
        if (!Page.IsPostBack)&lt;br /&gt;
            BindSections();&lt;br /&gt;
    }&lt;br /&gt;
    protected void grdSections_RowCommand(object sender, GridViewCommandEventArgs e)&lt;br /&gt;
    {&lt;br /&gt;
        int rowIndex = Int32.Parse((string)e.rumandArgument);&lt;br /&gt;
        string sectionName = (string)grdSections.DataKeys[rowIndex].Value;&lt;br /&gt;
        if (e.rumandName == &amp;quot;Protect&amp;quot;)&lt;br /&gt;
            ProtectSection(sectionName);&lt;br /&gt;
        if (e.rumandName == &amp;quot;UnProtect&amp;quot;)&lt;br /&gt;
            UnProtectSection(sectionName);&lt;br /&gt;
        BindSections();&lt;br /&gt;
    }&lt;br /&gt;
    private void ProtectSection(string sectionName)&lt;br /&gt;
    {&lt;br /&gt;
        Configuration config = WebConfigurationManager.OpenWebConfiguration (Request.ApplicationPath);&lt;br /&gt;
        ConfigurationSection section = config.GetSection(sectionName);&lt;br /&gt;
        section.SectionInformation.ProtectSection (&amp;quot;RsaProtectedConfigurationProvider&amp;quot;);&lt;br /&gt;
        config.Save(ConfigurationSaveMode.Modified);&lt;br /&gt;
    }&lt;br /&gt;
    private void UnProtectSection(string sectionName)&lt;br /&gt;
    {&lt;br /&gt;
        Configuration config = WebConfigurationManager.OpenWebConfiguration (Request.ApplicationPath);&lt;br /&gt;
        ConfigurationSection section = config.GetSection(sectionName);&lt;br /&gt;
        section.SectionInformation.UnprotectSection();&lt;br /&gt;
        config.Save(ConfigurationSaveMode.Modified);&lt;br /&gt;
    }&lt;br /&gt;
    private void BindSections()&lt;br /&gt;
    {&lt;br /&gt;
        Configuration config = WebConfigurationManager.OpenWebConfiguration (Request.ApplicationPath);&lt;br /&gt;
        List&amp;lt;SectionInformation&amp;gt; colSections = new List&amp;lt;SectionInformation&amp;gt;();&lt;br /&gt;
        foreach (ConfigurationSection section in config.SectionGroups[&amp;quot;system.web&amp;quot;].Sections)&lt;br /&gt;
            colSections.Add(section.SectionInformation);&lt;br /&gt;
        grdSections.DataSource = colSections;&lt;br /&gt;
        grdSections.DataBind();&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;html xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; &amp;gt;&lt;br /&gt;
&amp;lt;head id=&amp;quot;Head1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;Encrypt Config&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;form id=&amp;quot;form1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;div&amp;gt;&lt;br /&gt;
    &amp;lt;asp:GridView&lt;br /&gt;
        id=&amp;quot;grdSections&amp;quot;&lt;br /&gt;
        DataKeyNames=&amp;quot;SectionName&amp;quot;&lt;br /&gt;
        AutoGenerateColumns=&amp;quot;false&amp;quot;&lt;br /&gt;
        OnRowCommand=&amp;quot;grdSections_RowCommand&amp;quot;&lt;br /&gt;
        Runat=&amp;quot;server&amp;quot; &amp;gt;&lt;br /&gt;
        &amp;lt;Columns&amp;gt;&lt;br /&gt;
        &amp;lt;asp:ButtonField ButtonType=&amp;quot;Link&amp;quot; Text=&amp;quot;Protect&amp;quot; CommandName=&amp;quot;Protect&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;asp:ButtonField ButtonType=&amp;quot;Link&amp;quot; Text=&amp;quot;UnProtect&amp;quot; CommandName=&amp;quot;UnProtect&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;asp:CheckBoxField DataField=&amp;quot;IsProtected&amp;quot; HeaderText=&amp;quot;Protected&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;asp:BoundField DataField=&amp;quot;SectionName&amp;quot; HeaderText=&amp;quot;Section&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;/Columns&amp;gt;&lt;br /&gt;
    &amp;lt;/asp:GridView&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
== Encrypting Sections with the aspnet_regiis tool==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
To encrypt a section in the web configuration file, use the aspnet_regiis command-line tool. &lt;br /&gt;
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe&lt;br /&gt;
The following command encrypts the connectionStrings section of a configuration file located in a folder named MyWebApp:&lt;br /&gt;
aspnet_regiis -pef connectionStrings c:\Websites\MyWebApp&lt;br /&gt;
&lt;br /&gt;
To use the virtual path. &lt;br /&gt;
The following command encrypts the connectionStrings section of a configuration file located in a virtual directory named /MyApp:&lt;br /&gt;
-app option is used to specify the application&amp;quot;s virtual path.&lt;br /&gt;
aspnet_regiis -pe connectionStrings -app /MyApp&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>