Developing a module which included the uploading of a photo I encountered the error PageLoadException: Maximum request length exceeded. The image being uploaded was larger than the others in the test.
The full error message associated with the image upload was:
DotNetNuke.Services.Exceptions.PageLoadException: Maximum request length exceeded. ---> System.Web.HttpException: Maximum request length exceeded. at System.Web.HttpRequest.GetEntireRawContent() at System.Web.HttpRequest.GetMultipartContent() at System.Web.HttpRequest.FillInFormCollection() at System.Web.HttpRequest.get_Form() at System.Web.HttpRequest.get_HasForm() at System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) at System.Web.UI.Page.DeterminePostBackMode() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace ---
This error was generated by an image from a newer 14M digital camera.
To correct this error, and allow a larger image to be uploaded, either make a change to the web.config file and/or put a trap in file upload handler.
The web.config file is to be found at the root of the website. In the file the line of interest is:
<httpRuntime shutdownTimeout="120" executionTimeout="900" useFullyQualifiedRedirectUrl="true" maxRequestLength="12288" requestLengthDiskThreshold="12288" requestValidationMode="2.0" requestPathInvalidCharacters="<,>,*,%,:,\,?" />
I changed the maxRequestLength value from 12288 to 24576. The default value is 4096, which equates to 4MB.
Looking at some of images from the camera I found the size of the larger ones to be appox. 13MB. I chose to change the value to 16384 (16MB)
Making the above changes ensures that the website itself won’t be the cause of a failed image upload. However, IIS has its own timeout, by default this is set to 900, which equates to 15 minutes. Unless you are hosting your site on your own server this timeout may not be a factor which you are able to change. Also by increasing this value you are leaving more connections active which will impact on the performance of the server.
The visitor’s Internet connection will also play a part in whether they can upload an image. A slower link making it more likely that the IIS timeout will be reached.


