Export (0) Print
Expand All

MachineKeySection.DecryptionKey Property

Gets or sets the key that is used to encrypt and decrypt data, or the process by which the key is generated.

Namespace:  System.Web.Configuration
Assembly:  System.Web (in System.Web.dll)

[ConfigurationPropertyAttribute("decryptionKey", DefaultValue = "AutoGenerate,IsolateApps")]
[StringValidatorAttribute(MinLength = )]
[TypeConverterAttribute(typeof(WhiteSpaceTrimStringConverter))]
public string DecryptionKey { get; set; }

Property Value

Type: System.String
A key value, or a value that indicates how the key is generated. The default is "AutoGenerate,IsolateApps".

The DecryptionKey property is used for encryption and decryption, such as in Windows Forms authentication, and for view state when the Validation property is set to "3DES" or "AES".

Use the "AutoGenerate" option to specify that ASP.NET generates a random key and stores it in the Local Security Authority. The "AutoGenerate" option is part of the default value.

If you add the "IsolateApps" modifier to the "AutoGenerate" ValidationKey value, ASP.NET generates a unique encrypted key for each application by using each application's AppDomainAppVirtualPath. This is the default setting.

If you add the "IsolateByAppId" modifier to the "AutoGenerate" ValidationKey value, ASP.NET generates a unique encrypted key for each application by using each application's AppDomainAppId. If two distinct applications share a virtual path (perhaps because those applications are running on different ports), this flag can be used to further distinguish them from one another. The “IsolateByAppId” flag is understood only by ASP.NET 4.5, but it can be used regardless of the MachineKeySection.CompatibilityMode setting.

If you need to support configuration across a network of Web servers (a Web farm), set the DecryptionKey property manually to ensure consistent configuration. For information about how to manually generate values for the DecryptionKey attribute, see How To: Configure MachineKey in ASP.NET 2.0.

This property is typically set declaratively in the DecryptionKey attribute of the machineKey element of the Web.config file. For more information, see the machineKey element.

The following example demonstrates how to set the DecryptionKey property by using code. This example is part of a larger example provided for the MachineKeySection class.

// Display DecryptionKey property.
Console.WriteLine("DecryptionKey: {0}",
  configSection.DecryptionKey);

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft