For a project i was trying to pass formdata which holds input type file to be processed by asp.net web service (.asmx) . The service will upload the file to a specific folder and update the database with relevant values.
To my surprise i was not able to do that in the way i used to pass ajax data , it starts to throw some random error .
After a deep search, i found the answer in stackoverflow,
.NET will not allow the multipart/form-data for the content-type:
which is also having a link pointing to the Scottgu’s website.
essential these are trying to prevent JSON hijacking attacks. all the asmx webmethod unless until specified is always defaults to POST , the user has to specify explicitly the web method to use httpget to use GET method while making an ajax call.
and other important thing is
There is a built-in validation layer of protection that ASP.NET enforces for
both GET and POST based ASP.NET AJAX web methods, which is thatregardless
of the HTTP verb being used, ASP.NET always requires that the HTTP
Content-Type header is set to the value application/json. It this
content type header is not sent, ASP.NET AJAX will reject the request on the
server.