Wednesday, 15 September 2010

ajax - .NET WebMethod with xhrHttpRequest File Upload -



ajax - .NET WebMethod with xhrHttpRequest File Upload -

i trying asynchronous file upload using javascript in combination webmethod in vb.net

javascript:

xhr.open('post', "upload.aspx/upload", true); xhr.setrequestheader("content-type", "application/x-www-form-urlencoded"); var formdata = new formdata(); // append files (var in files) { formdata.append(base.el.name, files[i]); } xhr.send(formdata);

vb.net:

<web.services.webmethod(enablesession:=true)> _ public shared function upload() string homecoming "hello world!" end function

if utilize content-type=application/x-www-form-urlencoded, or multipart/form-data webmethod not hit, if utilize content-type=application/json, webmethod hit, response 500 message: invalid json primitive: ------webkitformboundary ...

is there way create ajax webmethod work multipart form data?

seems .net not allow multipart/form-data content-type:

json hijacking , how asp.net ajax 1.0 avoids these attacks1

there built-in validation layer of protection asp.net enforces both , post based asp.net ajax web methods, regardless of http verb beingness used, asp.net requires http content-type header set value application/json. content type header not sent, asp.net ajax reject request on server.

seems best way handle using generic .ashx file instead

ajax vb.net webmethod form-data

No comments:

Post a Comment