This sample app demonstrates problem with uploading big files in ASP.NET Core when hosting application in IIS web server
In the appsettings.json file:
-
Set the path for stored files (
StoredFilesPath
).- The sample app sets the value to
d:\\temp\\CoreUpload
, which assumes that a folder named CoreUpload exists in the foldertemp
D drive - The path must exist. Create a d:\temp\CoreUpload folder on the D: drive or set the path to a suitable location.
- The app's process requires read/write permissions to the path.
- IMPORTANT! Disable execute permissions for all users at the path.
- The sample app sets the value to
-
Set the file size limit (
FileSizeLimit
) in bytes. The sample app's default value of12884901888
(12,884,901,888 bytes) permits file uploads up to 12 GB. -
Publish it to IIS
-
Modify web.config to have
hostingModel="outofprocess"
and addrequestLimits maxAllowedContentLength="4294967295"
torequestFiltering
section
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<remove name="aspNetCore" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\SampleApp.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="outofprocess" requestTimeout="00:02:00" />
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="4294967295" />
</requestFiltering>
</security>
</system.webServer>
</location>
</configuration>
- Navigate to
http://localhost/StreamedSingleFileUploadPhysical
choose file greater then 2GB and click Upload button