MVC 中使用kindEditor 图片上传在IE 上进行上传出现的问题

   在IE 上使用KindEditor 进行单张图片上传的时候会出现一个下载安全警告,这样将会造成图片上传失败,出现的错误页面:

 

 

 将会出现这样的一个警告信息。

解决方案,: 是将上传的UpdataloadDetailsImg 方法的返回值 修改为 void

错误代码:

 public ActionResult UpdateloadDetailsImg()
        {
            string imageRemotePath = this.UploadImg();
            if (!string.IsNullOrWhiteSpace(imageRemotePath))
            {
                return Json(new
                {
                    error = 0,
                    url  = string.Format("{0}{1}", Constant.WECHATMALL_IMAGE_URL, imageRemotePath)

                });
            } 
                  
            return Json(new { error = 1, url = "上传图片发生错误!" });
        }

修改后的代码:

        public void UpdateloadDetailsImg()
        {
            string imageRemotePath = this.UploadImg();
            if (!string.IsNullOrWhiteSpace(imageRemotePath))
            {
                System.Web.HttpContext.Current.Response.ContentType = "text/html";
                System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
                System.Web.HttpContext.Current.Response.Write(new
                {
                    error = 0,
                    url  = string.Format("{0}{1}", Constant.WECHATMALL_IMAGE_URL, imageRemotePath)

                }.ToJson());

                System.Web.HttpContext.Current.Response.End();

            }
            else
            {
                System.Web.HttpContext.Current.Response.ContentType = "text/html";
                System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
                System.Web.HttpContext.Current.Response.Write(new { error = 1, url = "上传图片发生错误!" }.ToJson());
                System.Web.HttpContext.Current.Response.End();
            }
        }

这样就可以轻松搞定了。

 

posted on 2016-08-12 13:15  IT小伙儿  阅读(299)  评论(0编辑  收藏  举报