I am uploading files using SWFUpload. To get the data I need passed along with the file, I am adding post params to swfupload. The problem is that the custom model binder I have written is not called when the controller method is called by swfupload. Some of the properties of my model are set, but not the properties controlled by my custom binder, which means that it is using the default model binder.
When I use the following JQuery method, everything works as intended. So the problem is not that my custom model binder is set up incorrectly.
$.post('AsyncUpload', $('#uploadform').serialize());
The following is the code I am using to set up the post params and start the upload process. Note that I am aware of the setPostParams function, but for some reason it was not working for me, hence the work around. Also note that I verified that the post params are being set correctly in the Request variable on the server side.
$('#uploadbutton').click(function (e) {
e.preventDefault();
var data = $('#uploadform').serialize();
var res = $.parseQuery(data);
for (key in res) {
swfu.addPostParam(key, res[key]);
}
swfu.startUpload();
});
The pertinent swfupload variables are set as follows.
upload_url: '<%= Url.Action("AsyncUpload")%>', //This becomes /Home/AsyncUpload
use_query_string: true, // I have also tried setting this to false to no effect
This is my controller method, such as it is.
[HttpPost]
public bool AsyncUpload(EditModel model)
{
if (Request.Files.Count <= 0)
return false;
return true;
}
Any ideas why the custom model binder is not being invoked?