. NET mvc4 + ajaxfileupload.js resolves the Internet Explorer Pop-up Download dialog box issue

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.