I have a page web method, and I need to get access to the headers, and particularly the uploaded files. Is this possible? Can a web method receive a file?
If not, what would you recommend to upload files without post back? I am using the jQuery forms library that has support for this (and I have had it working with Django), however, I am having a hard time finding answers on how to do this with ASP.NET.
The jQuery Forms plugin converts a file upload to an iframe based post rather than an ajax post automatically. (This is because XHR doesn’t include files.) So you simply need to create a regular aspx page to handle the response. It can simply be empty except for a load event handler. If you need any response you can push it back in the HTML, which can be read from the body that is passed back.
For example, create a file upload that, on change calls this:
Note that “ajaxSubmit” here is a misnomer. In this case (with a file upload) it is actually a regular post that is made to look like an ajax request. Obviously, formId is the id of the form containing the file upload control.
and the response function is, (for example):
Create an aspx page with a div like this:
In the page load for this page do this:
HTH