One annoyance is the default file restriction size. In most instances when a content editor tries to upload a file, like a 14Md PDF they get a 'Maximum request length exceeded.' exception. If this is occurring within your production website and you have CustomErrors set to 'RemoteOnly', it can be troublesome for them to figure out what has gone wrong. There are two ways of fixing this issue.
The first is to set Umbraco to allow bigger files to be uploaded. To do this, open up your web.config file, which can be found in your website's webroot. In the web.config search for 'httpRuntime'. In this section, you should see the maxRequestLength. You will need to increase this number to allow for larger uploads. The maxRequestLength by default is set to 4MB, to change the upload to 20MB for example, you would use '20192'.
You may also want to add the executionTimeout property. This prolongs the period before Umbraco timeouts. Adding executionTimeout would look like this:
If you are using IIS7+ you may bump into this slightly different error:
HTTP Error 404.13 - Not Found The request filtering module is configured to deny a request that exceeds the request content length.
To fix this will also need to update the requestLimits maxAllowedContentLength property:
'maxAllowedContentLength' is measured in bytes, so 20MB would now be, '20971520'. These solutions will probably make the timeout error occur less frequently, but it's still a shit solution for content editors. One of my strong philosophies when building a website, is that creating a slick and easy back-end that content editors are happy with, is key to how the company perceives the success of a project. If the people who work with the CMS hate it, the whole company will know about it.
When a content editor uploads a large file that is too large and Umbraco just dies without telling them what the issue is, they'll get pissed off and complain about it. Instead, it's worth spending 15 minutes development time to make a solution that stops Umbraco from blowing up and providing feedback to content editors about what went wrong. To prevent Umbraco blowing up, you will need to hook into the web.configs Application_Error() method. If you haven't hooked up your Global.ascx file yet to work with custom code, I would recommend you read How To Enable The Global.asax in Umbraco
In our global.config when a 'File Upload Maximum Request Length Exceeded' exception occurs, we can catch the exception in Application_Error, using Server.GetLastError(). I've put my code in a separate method to make it easier to maintain, but you don't have to. In my IsMaxRequestException() method, all I'm really doing is checking the ErrorCode and the text of the inner exception to make sure it is the correct exception. If it is, I clear the exception from the stack and do a redirect to a custom HTML page I created myself. For reference, my FileToLarge.html file, now looks like this:
.NET 4 Version
If you are using .NET 4, then you can use this much simpler and easier to understand code:
In today's tutorial, I've covered how to fix upload size issue in Umbraco. You can increase the file size to however large you want too. In my opinion, just making the file size large doesn't fix the issue. A better solution is to prevent Umbraco blowing up and providing better feedback for content editors. We can do this by hooking into the Application_Error method in the global.ascx.