Absrtact: Everyone encountered the problem is different, in the Internet to find a big circle has not solved my problem! Because my environment, as the title suggests, solves this problem.
Main problem: The setting of the response header
Controller:
[HttpPost] Public Contentresult uploadfile (string user = wintabconst.space, int type = Configconst.zero, string imgtype = Wintabconst . Space, int objId = Configconst.zero, DateTime? Createdatetime = null) { HttpPostedFileBase imgfile = request.files["Imgfile"]; ATTACHMENTBLL ATTACHMENTBLL; if (!string. IsNullOrEmpty (user)) ATTACHMENTBLL = new ATTACHMENTBLL (user); else ATTACHMENTBLL = new Attachmentbll (); int userId = 0; Users usermodel = Attachmentbll.curuser; if (user! = null) userId = Usermodel.userid; Return Content (JavascriptHelper.JsonSerializer.Serialize (Attachmentbll.uploadfile (True, "", Imgfile, type, Imgtype, ObjId, UserId, Createdatetime))); }
Js:
$.ajaxfileupload ( { URL: "/companies/attachment/uploadfile", data: {"objId": ObjId, "Createdatetime": Createdatetime, "dir": "", "Type": "2", "userid": UserID, "User": $.cookie (' Logininfo ')}, type: "Post", Secureuri:false, dataType: "Text", fileelementid: "Imgfile", success:function (data) { if (data! = Null && data = = "") {//This judgment is because the format for Json,ie received the data as "", but the picture is also a successful issue of $ (". Uploadimg"). Hide (); $ (". Mask"). Hide (); } else if (data! = NULL && Data.error = = 0) {//My correct method of execution $ (". Uploadimg"). Hide (); $ (". Mask"). Hide (); } else { Alertalert ("Upload failed! "); } , error:function (e) { $.messager.alert (" Prompt "," Operation Error! "); } } );
. NET mvc4 + ajaxfileupload.js resolves the Internet Explorer Pop-up Download dialog box issue