Skip to content

Commit 12ebd5f

Browse files
Fix error System.IO.InvalidDataException: Multipart body length limit 134217728 exceeded making that limit configurable and with a default of 500MB instead of 128MB
1 parent 5e97036 commit 12ebd5f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

dotnet/src/dotnetcore/GxClasses.Web/Middleware/HandlerFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class AppSettings
2020
public BaseUrls BaseUrls { get; set; }
2121
public bool AnalyticsEnabled { get; set; }
2222
public int SessionTimeout { get; set; }
23+
public int MaxFileUploadSize { get; set; }
2324
}
2425

2526
public class BaseUrls

dotnet/src/dotnetcore/GxNetCoreStartup/Startup.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4-
using System.Reflection;
54
using System.Net;
65
using System.Threading.Tasks;
76
using GeneXus.Configuration;
87
using GeneXus.Http;
98
using GeneXus.HttpHandlerFactory;
109
using GeneXus.Services;
1110
using GeneXus.Utils;
12-
using GxClasses.Helpers;
1311
using GxClasses.Web.Middleware;
1412
using log4net;
1513
using Microsoft.AspNetCore;
@@ -18,6 +16,7 @@
1816
using Microsoft.AspNetCore.Diagnostics;
1917
using Microsoft.AspNetCore.Hosting;
2018
using Microsoft.AspNetCore.Http;
19+
using Microsoft.AspNetCore.Http.Features;
2120
using Microsoft.AspNetCore.Mvc;
2221
using Microsoft.AspNetCore.Rewrite;
2322
using Microsoft.AspNetCore.Routing;
@@ -95,6 +94,7 @@ public class Startup
9594

9695
static readonly ILog log = log4net.LogManager.GetLogger(typeof(Startup));
9796
const int DEFAULT_SESSION_TIMEOUT_MINUTES = 20;
97+
const int DEFAULT_MAX_FILE_UPLOAD_SIZE_BYTES = 500000000;
9898
public static string VirtualPath = string.Empty;
9999
public static string LocalPath = Directory.GetCurrentDirectory();
100100

@@ -144,6 +144,10 @@ public void ConfigureServices(IServiceCollection services)
144144
AppSettings settings = new AppSettings();
145145
Config.ConfigRoot.GetSection("AppSettings").Bind(settings);
146146

147+
services.Configure<FormOptions>(options =>
148+
{
149+
options.MultipartBodyLengthLimit = settings.MaxFileUploadSize==0 ? DEFAULT_MAX_FILE_UPLOAD_SIZE_BYTES : settings.MaxFileUploadSize;
150+
});
147151
ISessionService sessionService = GXSessionServiceFactory.GetProvider();
148152

149153
if (sessionService != null)

0 commit comments

Comments
 (0)