1

I am using the blueimp fileUpload plugin to send files to the server and in ie 8 and ie 9 it tries to prompt me to download a file. When I open the file it is perfect json.

I have tried setting the content type to text/plain as well as the dataType to text/plain but to no avail.

I am using FubuMVC as well so I cant just return a string. If it is not json then it tries to render a view.

var obj = {
            dataType: 'json',
            contentType: "application/json",
            url: uploadUrl,
            formData: formData,
            start: function(e, data) {
                $('#' + loadingDiv).dialog('open');
            },
            stop: function(e, data) {
                $('#' + loadingDiv).dialog('close');
            },
            add: function(e, data) {
                data.formData = obj.formData;
                data.submit();
            },

            always: function(e, data) {
                alert('done');
            }
        };

        $('#' + div).fileupload(obj);
segFault
  • 1,228
  • 2
  • 18
  • 41
  • have you tried content-type `application/json`? That should be the official mime type. – Louis Huppenbauer Feb 06 '14 at 23:18
  • Yes and that doesnt work. The issue is that if it thinks it is json and it is using an iFrame then it tries to download the result. I want to trick it to thinking its just text – segFault Feb 06 '14 at 23:25
  • Then try to provide some of your relevant code, otherwise it would be just like staggering around on a misty night. – Louis Huppenbauer Feb 06 '14 at 23:30

1 Answers1

1

If your action method returns a string, the content type is set to text/plain, and the browser should display a string instead of trying to download a file.

Or you can use IHttpWriter in your action method.

ulu
  • 5,872
  • 4
  • 42
  • 51
  • I cant do that because I am using FubuMVC and need to return an object – segFault Feb 07 '14 at 15:50
  • 1
    I'm using FubuMVC too. A string is an object, and a reference type, so it's perfectly valid for a return type. In fact, I used it yesterday, worked just fine. – ulu Feb 07 '14 at 18:14