Radi Atanassov

SharePoint MCM, MVP, MCT and owner of OneBit Software

Custom Upload Controls and the Maximum File Upload Size

If you’re creating a custom page or control that uploads files from a users PC (or somewhere else) you may get this error if the file is too big:

System.Web.HttpException: Maximum request length exceeded.

This is an ASP.NET error before the request is being handled by SharePoint (you can follow the stack trace to understand it a bit more). The challenge developers are facing is handling the exception and producing a nice & customized error message to users. You can easily overcome the problem by modifying the web.config of the Web Application, but that is not good practice and you have to worry about reproducing the modification for scalability and backup/restore purposes.

In a typical custom solution there is a nice solution to this problem. If you use Application Pages (those ASPX files that live in {SharePoint Root}\Templates\Layouts) you can place a web.config in your solution folder within the Layouts folder. Your web.config will go in:


Here’s what you need in the web.config:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>


  <location path="CustomUploadPage.aspx">


      <httpRuntime maxRequestLength="2097151" />




web.config’s are very flexible and the location element lets you apply your change exactly on the file that you need. This will work even if you are using an ASCX control located in the _CONTROLTEMPLATES folder. It is also a great approach as it can be packed into WSP’s and be part of an enterprise solution.

The number 2097151 is 2GB (boundary), the maximum SharePoint supported file size. It may be good to reduce this depending on your example.

The next point worth mentioning here is that the above setting alone won’t let you upload files over 50MB unless you configure the Web Application to allow it.


If the Web Application setting is below your file size you will get this exception:

Microsoft.SharePoint.SPException: The specified file is larger than the maximum supported file size.
NOTE: it has an ErrorCode of 2147024872

The good news is that you can handle the above exception with a simple Try…Catch, and that is all you need to facilitate a friendly, customized error message.

Hope this helps!

Pimp Your IDE: Visual Studio 2010 Themes and Skins

For those who know me, I have always been a HUGE fan of customizing my development environment. Well now with Visual Studio 2010 we can do more than what we could do with VS 2008… I’ve always known that, but now I found the right tool to help me do it.

Visual Studio Color Theme Editor lets you change the colors of VS 2010 and save a set as a “theme”. Here is my first VS 2010 dark theme:

Elite Dark


Just install the extension and open my theme and you are ready to go!

Download Visual Studio Color Theme Editor

Download my theme: Elite Dark (LINK FIXED!!!)

UPDATE: My initial version had dark shades on the grid, I made them a bit lighter. ZIP file updated.