diff --git a/src/Service/KeyGeneratorService.php b/src/Service/KeyGeneratorService.php
index 0e48053738b765d886cb7d9f26d047a4f66931f2..2e0dd3e3acdb418a51d09810da095594a59e2155 100755
--- a/src/Service/KeyGeneratorService.php
+++ b/src/Service/KeyGeneratorService.php
@@ -73,7 +73,12 @@ class KeyGeneratorService {
     $this->validator->validateNotFilePublicPath([$dir_path]);
 
     FileSecurity::writeHtaccess($dir_path);
-    FileSecurity::writeWebConfig($dir_path);
+    // As writeWebConfig method is deprecated and removed from D11.
+    // Also drupal dropped IIS support which require web.config so its ideal
+    // to have a check and handle the backward compatibility.
+    if (method_exists(FileSecurity::class, 'writeWebConfig')) {
+      FileSecurity::writeWebConfig($dir_path);
+    }
 
     // Create Keys array.
     $keys = KeyGenerator::generateKeys();