From 01de92107f3e71066b1905c45f46a4e728698920 Mon Sep 17 00:00:00 2001 From: Ruikuan Date: Fri, 29 Jan 2021 05:30:11 +0800 Subject: [PATCH] make Registry subkey writable (#21342) If not writable, sometimes you will suffer `UnauthorizedAccessException: Cannot write to the registry key.` I think a wide used docs should avoid that happen. --- .../data-protection/implementation/key-storage-providers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/security/data-protection/implementation/key-storage-providers.md b/aspnetcore/security/data-protection/implementation/key-storage-providers.md index bfd1699f10..06b846f0bd 100644 --- a/aspnetcore/security/data-protection/implementation/key-storage-providers.md +++ b/aspnetcore/security/data-protection/implementation/key-storage-providers.md @@ -122,7 +122,7 @@ Sometimes the app might not have write access to the file system. Consider a sce public void ConfigureServices(IServiceCollection services) { services.AddDataProtection() - .PersistKeysToRegistry(Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Sample\keys")); + .PersistKeysToRegistry(Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Sample\keys", true)); } ```