lith 5 jaren geleden
bovenliggende
commit
19b866a023

+ 16 - 6
dotnet/Vit/Vit.WebHost/Extensions/IWebHostBuilderExtensions_VitConfig.cs

@@ -18,17 +18,27 @@ namespace Vit.Extensions
             {
                 services.Configure(delegate (Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions options)
                 {                    
-                    //限制body的大小
+                    //限制body的大小
                     options.Limits.MaxRequestBodySize = Vit.Core.Util.ConfigurationManager.ConfigurationManager
                     .Instance.GetByPath<long?>("Vit.Kestrel.MaxRequestBodySize");
                 });
 
                 //解决Multipart body length limit 134217728 exceeded
-                //services.Configure<Microsoft.AspNetCore.Http.Features.FormOptions>(x =>
-                //{
-                //    x.ValueLengthLimit = int.MaxValue;
-                //    x.MultipartBodyLengthLimit = int.MaxValue; // In case of multipart
-                //});
+                services.Configure<Microsoft.AspNetCore.Http.Features.FormOptions>(x =>
+                {
+                    
+                    var ValueLengthLimit = Vit.Core.Util.ConfigurationManager.ConfigurationManager.Instance.GetByPath<int?>("Vit.Kestrel.ValueLengthLimit");
+                    if (ValueLengthLimit.HasValue)
+                    {
+                        x.ValueLengthLimit = ValueLengthLimit.Value;
+                    }
+
+                    var MultipartBodyLengthLimit = Vit.Core.Util.ConfigurationManager.ConfigurationManager.Instance.GetByPath<long?>("Vit.Kestrel.MultipartBodyLengthLimit");
+                    if (MultipartBodyLengthLimit.HasValue)
+                    {
+                        x.MultipartBodyLengthLimit = MultipartBodyLengthLimit.Value;// In case of multipart
+                    }        
+                });
             });
 
             if (null == Vit.Core.Util.ConfigurationManager.ConfigurationManager.Instance.Get<JToken>("Logging"))

+ 9 - 3
dotnet/netcore/Gateway/App.Gateway/appsettings.json

@@ -161,9 +161,15 @@
     },
 
 
-    "Kestrel": {
-      /* the maximum allowed size of any request body in bytes.  When set to null, the maximum request body size is unlimited. */
-      "//MaxRequestBodySize": 100000000
+    "//Kestrel": {
+      /* (int64) the maximum allowed size of any request body in bytes.  When set to null, the maximum request body size is unlimited. */
+      "MaxRequestBodySize": 2000000000,
+
+      /* (int32) A limit on the length of individual form values. Forms containing values that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
+      "ValueLengthLimit": 2000000000,
+
+      /* (int64) A limit for the length of each multipart body. Forms sections that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
+      "MultipartBodyLengthLimit": 2000000000
     }
 
   }

+ 9 - 3
dotnet/netcore/ServiceCenter/App.Gover.Gateway/appsettings.json

@@ -164,9 +164,15 @@
     },
 
 
-    "Kestrel": {
-      /* the maximum allowed size of any request body in bytes.  When set to null, the maximum request body size is unlimited. */
-      "//MaxRequestBodySize": 100000000
+    "//Kestrel": {
+      /* (int64) the maximum allowed size of any request body in bytes.  When set to null, the maximum request body size is unlimited. */
+      "MaxRequestBodySize": 2000000000,
+
+      /* (int32) A limit on the length of individual form values. Forms containing values that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
+      "ValueLengthLimit": 2000000000,
+
+      /* (int64) A limit for the length of each multipart body. Forms sections that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
+      "MultipartBodyLengthLimit": 2000000000
     }
 
   }

+ 9 - 3
dotnet/netcore/ServiceCenter/App.ServiceCenter/appsettings.json

@@ -423,9 +423,15 @@
     },
 
 
-    "Kestrel": {
-      /* the maximum allowed size of any request body in bytes.  When set to null, the maximum request body size is unlimited. */
-      "//MaxRequestBodySize": 100000000
+    "//Kestrel": {
+      /* (int64) the maximum allowed size of any request body in bytes.  When set to null, the maximum request body size is unlimited. */
+      "MaxRequestBodySize": 2000000000,
+
+      /* (int32) A limit on the length of individual form values. Forms containing values that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
+      "ValueLengthLimit": 2000000000,
+
+      /* (int64) A limit for the length of each multipart body. Forms sections that exceed this limit will throw an System.IO.InvalidDataException when parsed. */
+      "MultipartBodyLengthLimit": 2000000000
     }
 
   }