MachineKeySection.DecryptionKey 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定用於加密與解密資料的金鑰,或金鑰產生的過程。
public:
property System::String ^ DecryptionKey { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.TypeConverter(typeof(System.Configuration.WhiteSpaceTrimStringConverter))]
[System.Configuration.ConfigurationProperty("decryptionKey", DefaultValue="AutoGenerate,IsolateApps")]
[System.Configuration.StringValidator(MinLength=1)]
public string DecryptionKey { get; set; }
[<System.ComponentModel.TypeConverter(typeof(System.Configuration.WhiteSpaceTrimStringConverter))>]
[<System.Configuration.ConfigurationProperty("decryptionKey", DefaultValue="AutoGenerate,IsolateApps")>]
[<System.Configuration.StringValidator(MinLength=1)>]
member this.DecryptionKey : string with get, set
Public Property DecryptionKey As String
屬性值
一個鍵值,或表示鍵值如何產生的值。 預設是「自動生成,隔離應用程式」。
- 屬性
範例
以下範例示範如何利用程式碼設定該 DecryptionKey 屬性。 此範例是本類別更大 MachineKeySection 範例的一部分。
// Display DecryptionKey property.
Console.WriteLine("DecryptionKey: {0}",
configSection.DecryptionKey);
' Display DecryptionKey property.
Console.WriteLine("DecryptionKey: {0}", configSection.DecryptionKey)
備註
此 DecryptionKey 屬性用於加密與解密,例如在 Windows Forms 認證中,以及設定為「3DES」或「AES」時 Validation 的視圖狀態。
使用「自動生成」選項指定 ASP.NET 產生隨機金鑰並將其儲存在地方安全管理局。 「自動生成」選項是預設值的一部分。
如果你在「AutoGenerate」 ValidationKey 值中加上「IsolateApps」修飾符,ASP.NET 會利用每個應用程式的 AppDomainAppVirtualPath。 這是預設設定。
如果你在「AutoGenerate」 ValidationKey 值中加上「IsolateByAppId」修飾符,ASP.NET 會利用每個應用程式的 AppDomainAppId。 如果兩個不同的應用程式共用虛擬路徑(可能因為它們在不同埠上運行),這個旗標可以用來進一步區分它們。 「IsolateByAppId」旗標僅能被 ASP.NET 4.5 理解,但無論設定為何 MachineKeySection.CompatibilityMode 都可以使用。
如果你需要支援跨網路伺服器(網路農場)的設定,請手動設定屬性 DecryptionKey 以確保配置一致。 關於如何手動產生屬性值 DecryptionKey 的資訊,請參見 ASP.NET 2.0 中的 How To: Configure MachineKey。
此屬性通常以宣告式方式設定於 DecryptionKey Web.config 檔案的 machineKey 元素屬性中。 欲了解更多資訊,請參閱 machineKey 元素。