Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a custom web part in a sandbox solution. Inside of the web part I have added an <input type="file" />. Upon postback I read the file using HttpContext.Current.Request.Files and save the file in a document library.

The web part itself lives inside of a custom aspx as a <WebPartPages:SPUserCodeWebPart>. The aspx is deployed as a module and there is no master-page. The only markup in the aspx, except for the web-part is

<form method='post' runat="server" action="FileUploadPage.aspx" enctype="multipart/form-data">

and an <SharePoint:FormDigest> control.

This mechanism works fine when uploading small files. However, if the file being uploaded is larger than 80KB, the web part fails with the dreaded error message:

"Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: An unexpected error has occurred."

This exception cannot be caught via a catch statement and Fiddler tells me that the server returns a regular 200 success response containing the above error message. Also, if I attach a debugger to the web part code, the code is never hit. So, it's not an http error but rather an error that occurs between the moment the POST arrives on the server and the code-behind of the web part is executed.

My only explanation of this error is that there is some arbitrary limit to the size of the http request that you can post in custom aspx pages.

Is there another way of doing a custom file upload? I have considered uploading the file in chunks using AJAX. But I haven't found a way to partially upload a file in a document library.

share|improve this question
    
SharePoint pages can only have one form element in them. Does your module create pages that have two? –  James Love Oct 6 '11 at 13:54
    
@James, no it's only one form tag in the resulting html. –  Jivko Petiov Oct 6 '11 at 13:56
    
Anything in the ULS or server event logs? –  ToddersLegrande Jun 12 '12 at 12:32

1 Answer 1

Have you tried debugging by attaching to the SPUCWorkerProcess.exe?

Also check the resouce limits that are placed on Sandbox solutions here: http://msdn.microsoft.com/en-us/library/gg615462.aspx. That page shows how to remove these limits as well, although that isn't a good idea. I would make this asyncronous rather than syncronous if that is the case. Maybe call a webservice or external API outside of the sandboxed solution.

Hope this helps!

share|improve this answer
    
Hi, did this answer help? Any updates? –  onzur Jun 15 '12 at 0:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.