c# - IE8 prompts download json response -
i've been trying out jquery form plugin , works wonderfully. oh, except ie8. it's ie8.
anyways, on success response callback, ie8 prompts me download response instead of calling success function.
here javascript code looks like
$("#form1").ajaxform({ url: "http://localhost:4887/api/file/post", type: "post", success: function (data) { //response stuff here } });
i've tried specifying datatype ajax form, woe me, didn't work
the thing returning server string. once again, ie8 prompts me download string instead of calling success function. after research, understand might have modify http headers? shed light on this? or give way of going this?
update here brief @ c# controller
public class filecontroller : apicontroller { public jsonresult post() { httppostedfile file = null; string encodedstring = //do stuff here base64 string modelname obj = new modelname(); obj.characters = encodedstring; jsonresult result = new jsonresult(); result.data = obj; result.contenttype = "text/html"; return result; }
request headers...
accept application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, /
accept-language en-us
user-agent mozilla/4.0 (compatible; msie 8.0; windows nt 6.1; wow64; trident/4.0; slcc2; .net clr 2.0.50727; .net clr 3.5.30729; .net clr 3.0.30729; media center pc 6.0; .net4.0c; .net4.0e; infopath.3; .net clr 1.1.4322)
content-type multipart/form-data; boundary=---------------------------7dd3e622907b6
accept-encoding gzip, deflate
proxy-connection keep-alive
content-length 300
response headers http/1.1 200 ok cache-control no-cache
pragma no-cache
content-type application/json; charset=utf-8
expires -1
server microsoft-iis/8.0
x-aspnet-version 4.0.30319 x-powered-by asp.net
try this:
[httppost] public jsonresult post() { httppostedfile file = null; ; string encodedstring = //get file contents, , base64 encoded string modelname obj= new modelname(); obj.characters = encodedstring; return json(obj, "text/html"); }
update:
or change content-type
response.content.headers.contenttype = new mediatypeheadervalue("text/html");
example:
public jsonresult post() { httppostedfile file = null; ; string encodedstring = //get file contents, , base64 encoded string modelname obj= new modelname(); obj.characters = encodedstring; response.content.headers.contenttype = new mediatypeheadervalue("text/html"); return json(obj, "text/html"); }
Comments
Post a Comment