ajax - .NET WebMethod with xhrHttpRequest File Upload -
I am trying to upload an asynchronous file using JavaScript with WebMethod in VB.NET
Javascript:
xhr.open ('post', "upload.aspx / upload", is true); Xhr.setRequestHeader ("content-type", "app / x-www-form-urxed"); Var formadata = new form data (); // files (for files in var i) {formData.append (base.el.name, files [i]); } Xhr.send (formData); VB.NET:
& web.Services.WebMethod (enabled session = true) & gt; _ Public Share Function Upload () "Hello World as String Return!" If I use content-type = application / x-www-form-urlencoded , or multipart / form-data , then the last function If I use content-type = application / json , then webmath can not hit, webmother is hit, but the response message is 500: Invalid JSON Primitive: ---- - WebCard frame ... Is there a way that AJAX webmath can work with multipart form data?
Net content type will not allow multipart / form-data :
Security has an inherent verification layer that uses ASP.NET Is implemented for both GET and Post based ASPNAT AJAX web methods, without using the HTTP verb, ASP.Net is always required to set HTTP content-type header value to app / json This content type header is not sent ASP.NET will reject the request on the AJAX server. The best way is to make a general rather than that. >
Comments
Post a Comment