Is there a way to ignore the maxRequestLength limit of 2GB file uploads?

Here’s where I’m setting maxRequestLength to 2GB (the max value), which indicates the maximum request size supported by ASP.NET:

<system.web>
    <httpRuntime maxRequestLength="2097151" executionTimeout="3600"/>
    ...

and here I’m setting the maxAllowedContentLength to 4GB (the max value), which specifies the maximum length of content in a request supported by IIS

<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="4294967295"/>
        </requestFiltering>
    </security>
    ...

I’d like to be able to upload files up to 4GB, but I’m limited by the maxRequestLength field.

I noticed that this third party upload tool (http://www.element-it.com/onlinehelp/webconfig.html) has a ignoreHttpRuntimeMaxRequestLength property, which allows it to upload files up to 4GB.

Does anyone know if I can ignore the maxRequestLength value like this other upload tool does?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Considering the Type of MaxRequestLength is a Int, at the moment there is no way to parse a value higher than Int.Max correctly.

I heard they might be increasing IIS8 but nothing concrete from Microsoft as of yet. The only way I’ve seen in .Net 4.5 is to use HttpRequest.GetBufferlessInputStream which

Gets a Stream object that can be used to read the incoming HTTP entity body, optionally disabling the request-length limit that is set in the MaxRequestLength property.

Method 2

In my case these were the changes I needed to apply:

<system.web>
    <httpRuntime targetFramework="4.6.1" maxRequestLength="2147483647" />
</system.web>

<system.webServer>
     <serverRuntime uploadReadAheadSize="2147483647" />
     <security>
        <requestFiltering>
           <requestLimits maxAllowedContentLength="2147483647" />
        </requestFiltering>
     </security>
</system.webServer>

In order to add the serverRuntime follow the intructions in the first answer of this question

Method 3

You should be able to override the settings inside machine.config by adding the same node into your application’s web.config like so. Microsoft has some information about ASP.NET Configuration File Hierarchy and Inheritance.

NOTE: Erik Philips is right and the max size of maxRequestLength is 2,147,483,647 (Int32.MaxValue). This answer is to illustrate how to override a setting defined in machine.config (or any .config) from within your application’s web.config/

<configuration>
    ...
    <system.web>
        <httpRuntime maxRequestLength="2147483647"/>
    ...
    ...
    </system.web>
    ...
</configuration>

In doing this though, you might also want to increase your timeout or it might, well, time out.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x