Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Add fallback for data protection keys folder

KrzysztofPajak22325bcfc0b5
diff --git a/src/Web/Grand.Web.Common/Infrastructure/ServiceCollectionExtensions.cs b/src/Web/Grand.Web.Common/Infrastructure/ServiceCollectionExtensions.cs
index f0041ceab..f5fc5049d 100644
--- a/src/Web/Grand.Web.Common/Infrastructure/ServiceCollectionExtensions.cs
+++ b/src/Web/Grand.Web.Common/Infrastructure/ServiceCollectionExtensions.cs
@@ -123,7 +123,9 @@ public static class ServiceCollectionExtensions
{
var securityConfig = new SecurityConfig();
configuration.GetSection("Security").Bind(securityConfig);
- var dataProtectionKeysFolder = new DirectoryInfo(securityConfig.KeyPersistenceLocation);
+ var keyPersistenceLocation = string.IsNullOrEmpty(securityConfig.KeyPersistenceLocation)
+ ? "/App_Data/DataProtectionKeys" : securityConfig.KeyPersistenceLocation;
+ var dataProtectionKeysFolder = new DirectoryInfo(keyPersistenceLocation);
//configure the data protection system to persist keys to the specified directory
services.AddDataProtection().PersistKeysToFileSystem(dataProtectionKeysFolder);
}