Windows Azure の共有 Web サイトを使用しています。web.config の一部を暗号化したいのですが、次のエラーが発生します。
プロバイダー 'RsaProtectedConfigurationProvider' を使用して復号化できませんでした。プロバイダーからのエラー メッセージ: RSA キー コンテナーを開けませんでした。
サイトにそのファイルを暗号化するページがありますが、数時間後にこのエラーが発生します。マシン キーを Azure に送信する必要がありますか? または、使用できるものを Azure が持っていますか?
構成ファイルを暗号化するには、次のコードを使用します。
/// <summary>
/// About view for the website.
/// </summary>
/// <returns>Action Result.</returns>
public ActionResult About()
{
Configuration objConfig =
WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
AppSettingsSection objAppsettings =
(AppSettingsSection)objConfig.GetSection("appSettings");
if (!objAppsettings.SectionInformation.IsProtected)
{
objAppsettings.SectionInformation.ProtectSection(
"RsaProtectedConfigurationProvider");
objAppsettings.SectionInformation.ForceSave = true;
objConfig.Save(ConfigurationSaveMode.Modified);
}
return View();
}