Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 ValidationKey Property

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
MachineKeySection..::.ValidationKey Property

Gets or sets the key that is used to validate encrypted data, or the process by which the key is generated.

Namespace:  System.Web.Configuration
Assembly:  System.Web (in System.Web.dll)
Visual Basic (Declaration)
<StringValidatorAttribute(MinLength := )> _
<ConfigurationPropertyAttribute("validationKey", DefaultValue := "AutoGenerate,IsolateApps")> _
<TypeConverterAttribute(GetType(WhiteSpaceTrimStringConverter))> _
Public Property ValidationKey As String
Visual Basic (Usage)
Dim instance As MachineKeySection
Dim value As String

value = instance.ValidationKey

instance.ValidationKey = value
C#
[StringValidatorAttribute(MinLength = )]
[ConfigurationPropertyAttribute("validationKey", DefaultValue = "AutoGenerate,IsolateApps")]
[TypeConverterAttribute(typeof(WhiteSpaceTrimStringConverter))]
public string ValidationKey { get; set; }
Visual C++
[StringValidatorAttribute(MinLength = )]
[ConfigurationPropertyAttribute(L"validationKey", DefaultValue = L"AutoGenerate,IsolateApps")]
[TypeConverterAttribute(typeof(WhiteSpaceTrimStringConverter))]
public:
property String^ ValidationKey {
    String^ get ();
    void set (String^ value);
}
JScript
public function get ValidationKey () : String
public function set ValidationKey (value : String)

Property Value

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

The ValidationKey property is used when enableViewStateMAC is true to create a message authentication code to ensure that view state has not been tampered with. The ValidationKey property is also used to generate out-of-process, application-specific session IDs to ensure that session state variables are isolated between applications.

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 ValidationKey value, ASP.NET generates a unique encrypted key for each application by using each application's application ID. IsolateApps is also part of the default value.

If you need to support configuration across a network of Web servers (a Web farm), set the ValidationKey property manually to ensure consistent configuration.

The following example demonstrates how to use the ValidationKey property. This code example is part of a larger example provided for the MachineKeySection class.

Visual Basic
' Display ValidationKey property.
Console.WriteLine("ValidationKey: {0}", _
 configSection.ValidationKey)

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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker