I'm struggeling getting the Blueimp jQuery File-Uploader working on MVC 3 with IIS 7.5 on Windows Server 2008 R2. I'm using an HttpHandler to handle the Upload, which get's called. But the HttpHandler never recieves a file nor the HttpMethod "POST" or "PUT", always "OPTIONS". Has anyone an idea what is gouing wrong here?
The only message I get on the fail-callback from the uploader is "error".
Here my JS:
$('#fileupload').fileupload(
{
acceptFileTypes: /(\.|\/)(pdf)$/i,
fail: function (e, data) {
alert("Error: " + data.errorThrown + " Text-Status: " + data.textStatus);
// data.jqXHR;
},
maxNumberOfFiles: 1
/*add: function (e, data) {
data.formData = [{ name: "name1", value: "1" }, { name: "name2", value: "2"}];
data.submit();
},
submit: function (e, data) {
//data.formData = [{ name: "name1", value: "1" }, { name: "name2", value: "2"}];
}*/
}
);
Thank you very much for any help!
Okay adding some code did the trick:
Server-side:
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "http://example.net");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Credentials", "true");
Client-side:
$('#fileupload').fileupload(
{
xhrFields: {
withCredentials: true
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With