Request Filtering module is configured to deny a request that exceeds request content length

It's been a while since I last wrote on this blog. Been busy with work + real life. Anyway, here's what I encountered a couple of days ago.

We were working on a module that would allow users to upload files to the server (the file is stored in SQL Server as VARBINARY). The maximum allowed file size to be uploaded was made configurable through web.config file. We set those to be 50mb. When we tried to upload a 36mb file, IIS7 gave us this error:

Most google search results says that we have to add the following entry to our web.config file (the value for maxAllowedContentLength could be different from below):-

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

The problem is, this setting will NOT work with .NET 1.1 (oh yeah, you heard that right! I was working on .NET 1.1... **sigh**) on IIS7 because it does not know the <system.webServer> property. Further searching yield us with the solution. Here's the solution:-

1) Open notepad (as Administrator)
2) Open the file:

%windir%\system32\inetsrv\config\applicationHost.config

3) Find:
</requestFiltering>

4) Add before that </requestFiltering> line.
<requestLimits maxAllowedContentLength="2000000000" />

5) Final applicationHost.config file should be (only related part shown):
      <requestLimits maxAllowedContentLength="2000000000" />
    </requestFiltering>
  </security>