asp.net - 400 error when posting multipart formdata to a WCF service when file reaches certain size -
asp.net - 400 error when posting multipart formdata to a WCF service when file reaches certain size -
problem:
i trying upload file web service using jquery ajax , javascript formdata object. works fine files under 60kb in size. however, files above 70kb "400 bad request" response server. i'm missing somewhere, can't seem find if. ideas of should looking find source of fault?
fails in both dev environment , in production environment. tried several different browsers. behavior independent of file content. binary, text, etc. behave same. tried using raw xmlhttprequest instead of jquery ajax shown below, encountered same behavior. server settings: my web service hosted within sharepoint 2010 application (asp.net iis .net 3.5)i've checked httpruntime setting in web.config create sure sufficiently big:
httpruntime maxrequestlength="102400" executiontimeout="3600" i've checked requestlimits setting in applicationhost.config file:
requestlimits maxallowedcontentlength="1024000000" client code: the client code packing formdata object file , info in json string:
formsubmission.prototype.attach = function (servicepath, fileinputelement, successcallback, failedcallback) { if (typeof window.formdata === 'undefined') { alert(cob.basicforms.browser_support_msg); // more work have done deal ie 8 , 9. homecoming false; } var baseservicepath = cob.basicforms.service_address; var formdata = new formdata(); // object sent json. of properties // necessary server process file properly. formdata.append('submission', json.stringify(this)); var filename = $(fileinputelement).val().split('\\').pop(); // take 1 file @ time... formdata.append('file', fileinputelement.files[0], filename); var jqxhr = $.ajax({ type: "post", url: baseservicepath + "//attachfile", data: formdata, contenttype: false, processdata: false, cache: false, datatype: "json" }) .done(successcallback) .fail(failedcallback); homecoming true; } server code: as expected server side code never gets nail when 400 error returned. server side code does, however, work fine when file under 60k. here basic signature decorations:
[operationcontract] [webinvoke( method = "post", bodystyle = webmessagebodystyle.bare, requestformat = webmessageformat.json, responseformat = webmessageformat.json, uritemplate = "attachfile")] formattachmentresult attachfile(); any ideas welcome.
sleeping on helps. forgot open allowed message size in section of web.config. default limits messages 65kb. hope helps else when trying set knobs , switches...
http://msdn.microsoft.com/en-us/library/ms731361(v=vs.90).aspx
additional note:for sharepoint people, since service hosted in vti_bin, modifying web.config not possible, since sharepoint automagically hooks binding programmatically services deployed there. around this, custom service mill class can used gain access settings programmatically. see post more information.
asp.net ajax sharepoint file-upload multipartform-data
Comments
Post a Comment