RAPID PUBLISHING ARTICLES PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.
Create a custom ASPX page and hosted Multi-Upload control (STSUpld.UploadCtl) inside it. This page is hosted within SharePoint's _layouts folder. We are posting the data from the control to another custom ASPX page (also hosted in _layouts folder), which handles the actual upload of data to a SharePoint document library.
Web.Config file's maxRequestLength is set to 50 MB (by default).
If the total size of files to be uploaded in the custom page is less than 50 MB, this custom solution works fine. But when the total request size is beyond 50 MB, the custom ASPX page will do a refresh rather than uploading anything. There is no error displayed.
SharePoint's default multi-upload functionality works fine with larger requests.
When submitting data to a custom ASPX page and the request size is larger than the maxRequestLength specified in web.config, SharePoint returns the error page which the multi-upload control is not able to parse.
By default, SharePoint's multi-upload control posts the files to the shtml.dll file in the _vti_bin folder. As shtml.dll is an unmanaged C++ ISAPI component limits defined in Web.config or .net do not apply to it so it is able to take arbitrary size requests and work upon it and return the data in the format expected by the upload control.
The upload control expects the data to be returned inside an HTML comment format:
<!-- commentElt Your Custom Message -->
"Your Custom Message" is picked up by the control and displayed to the user in the browser.
When upload control (STSUpld.UploadCtl) posts data to custom ASPX pages, ASP.Net Runtime examines the total Request Length, if it exceeds the limit defined by maxRequestLength property, it raise the exception and returns the error page to the upload control, the upload control does not know how to parse the error page and then simply navigates to the default redirection page.
There are three methods to work around the problem.
Method 1
Change the maxRequestLength value in the Web.config to allow .NET runtime to pass a large request size.
Method 2
Write a custom multiple upload control and use it to handle the data as it comes. This would still hit the .NET request limit if you are sending the data to a managed component but as it is your custom control you would be able to handle the exception thrown by .NET runtime.
Method 3
Write a custom ISAPI module to be used instead of shtml.dll. Then you can use the existing control to post data to your custom ISAPI and handle the request there as and how needed. You would not hit any .NET imposed limits on request length here. You can then analyze the uploaded files and return the message in the format expected by upload control and then it would be displayed back to your user page.
MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALSâ€) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.