Friday 20 December 2013

IIS 7 File Uploads: maximum size restricted per default

I was working on an updated way to attach files to tickets asynchronously via the Kendo Upload component. Everything was working smoothly on my development machine. I then played a local release on my own IIS. From that point on I realized that every file bigger than 30Mb that I was trying to upload was failing.
I captured the server response with fiddler, 404 page not found. How can this be? I attached the process to VS Debugger, which seemed to be working ok, but the breakpoint inside my Save() method was never hit, except for that times that I was trying to upload a smaller than 30Mb file…

Irritating huh? Well, this is what is actually going on. I found the answer on this excellent post by Web Trenches. IIS 7 limits maximum upload file size to 30Mb by default. This can however be changed and there are 2 ways to do it:



1. At site level: Insert this section to your web.config file.
<system.webServer>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="524288000"/>
            </requestFiltering>
        </security>
</system.webServer>

2. Via the GUI of IIS: Select the corresponding website in IIS –> Request Filtering –> Right click in the window –> Edit Feature Settings –> Maximum Allowed Content Length (Bytes). Change the value to your needs and you are good to go.
Keep in mind that if your website is running behind a proxy or firewall and you have completed the steps above correctly, there might still be problems that lie on such restrictions.
Also remember, if you use the 2nd solution, every time you Publish changes to the website, this value is reset to default 30Mb. Thus, the first approach provides a more solid way to go past this irritating Microsoft Bug Feature.

No comments:

Post a Comment