IIS - Trouble uploading file larger then 30 mb on IIS 7,0 server.

Asked By Massimo DJG on 28-Apr-11 06:54 AM
Hi to all,
i've build an application in Visual Basic, this application has the function to upload different file on a server directory.
Two months ago i've installed in my IIS 7.0 on Windows Vista, Webdav and the request filtering extensions.
So i've setted the size limit in request filtering mask in IIS, and so i was in the condition to upload files over the default 30 mb size.
I use the vb function webclient.uploadfile to make this operation, and now i'm trying with async function of this, that is, webclient.uploadfileasync.
Yesterday, i've tried again to make an upload of a file over 30mb , but the system reject the request giving me an 500.0 error in log files.
The strange thing is that the application during the operation, upload the file in the server destination directory, but it doesn't close it, it appears that the server at a certain point stop any connection with the client, in fact, the handler fileuploadcompleted is never call in the application.
So i stop the application and the file dissappear from the directory, and the cpu of the system start go to 100%, and sometimes after some minutes it drops from these cpu usage %.

Thanks in advance for the help.

Massimo.
Jitendra Faye replied to Massimo DJG on 28-Apr-11 07:00 AM
I think you want to increase the upload file size limit-

then In the web.config.comments file, find a node called <httpRuntime>

and change-maxRequestLength attribute

<httpRuntime 
 executionTimeout="110" 
 maxRequestLength="4096"   //geive here your limit 

Riley K replied to Massimo DJG on 28-Apr-11 07:11 AM

By default, IIS7 limits file upload to 30MB.  Oddly, it returns a 404 error if someone uploads something larger than 30MB.   The docs from Microsoft are a little confusing on this, so I thought I would try to clarify.

According to the following article, you can "Remove the maxAllowedContentLength property." from the applicationhost.config file in IIS7 to lift the 30MB limit.  

So, my assumption on this is that the 30MB limit is somewhere internal to IIS7.  The article also doesn't say where to ADD the entry requestLimits node if it isn't already there.

Luckily, there is an alternate solution that can be enabled at the site level rather than server-wide.

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

If you add the above code to the web.config file for your site, you can control the maximum upload size for your site.  In many cases, the system.webServer node will already be in the file, so just add the security node within that.

Note that the maxAllowedContentLength is in BYTES not kilobytes.

You may also need to restart your Web site (not the whole server) to enable the setting.