We needed to do 4 things for our .NET Web Api project (.NET Framework):
1. In web.config add:
<system.webServer> <security> <requestFiltering> <requestLimits maxAllowedContentLength="4294967295" /> </requestFiltering> </security>
2. Also add to web.config:
<system.web> <httpRuntime targetFramework="4.7.1" maxRequestLength="2147483647" />
3. For large queries, 64-bit is required. In the properties of the Web Api project, when running locally in IIS Express, set 64-bit:
When publishing, ensure that the application pool supports the 64-bit version.
4. We noticed that requests take up memory for a long period of time: let your API controllers implement the base API controller. In this database, the api controller overrides the dispose method and removes the garbage:
protected override void Dispose(bool disposing) { base.Dispose(disposing); GC.Collect(); }
I do not recommend forcing garbage collection. You should use the visual studios built into the diagnostics to take pictures before and after the problems, and then compare the memory to see what it absorbs.
source share