. Net mvc4 + ajaxfileupload. js solves the problem of the pop-up Download Dialog Box in IE browser.
Abstract: Everyone encounters different problems. I have not solved my problems after finding a large circle on the Internet! This problem is solved because my environment is shown in the title.
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 = "") {// The result is that the format is json and the data received by IE is "", but the figure shows a successful transfer problem $ (". uploadImg "). hide (); $ (". mask "). hide ();} else if (data! = Null & data. error = 0) {// my correct execution method $ (". uploadImg "). hide (); $ (". mask "). hide ();} else {AlertAlert ("Upload Failed! ") ;}}, Error: function (e) {$. messager. alert (" prompt "," Operation error! ");}});