Froala WYSIWYG编辑器 - Asp.net MVC

Froala WYSIWYG编辑器 - Asp.net MVC

问题描述:

我被用于Froala WYSIWYG Editor。已上传的图像已成功保存在正确的路径中,但未在编辑器中显示。Froala WYSIWYG编辑器 - Asp.net MVC

<script> 
     $(function() { 
      $('#PostDesc').froalaEditor({ 
       imageButtons: ["removeImage", "replaceImage", "linkImage"], 
       borderColor: '#00008b', 
       imageUploadURL: '@Url.Action("FroalaUploadImage", "Posts")', 
       imageParams: { postId: "123" }, 
       enableScript: false, 
       fileUploadURL: '@Url.Action("FroalaUploadFile", "Posts")', 
       fileUploadParams: { postId: "123" } 
      }); 
     }); 
</script> 

操作:

[HttpPost] 
public ActionResult FroalaUploadImage(HttpPostedFileBase file, int? postId) 
{ 
    var fileName = Path.GetFileName(file.FileName); 
    var rootPath = Server.MapPath("~/img/Post/"); 
    file.SaveAs(Path.Combine(rootPath, fileName)); 
    return Json(new { link = "img/Post/" + fileName }, JsonRequestBehavior.AllowGet); 
} 

有什么不对return Json(new { link = "img/Post/" + fileName }, JsonRequestBehavior.AllowGet);

更新:

我使用的区域这个编辑器和它接缝,我必须改变网址。

我写

return Json(new UrlHelper(this.Request.RequestContext).Content("~/img/Post/" + fileName), JsonRequestBehavior.AllowGet); 

代替

return Json(new { link = "img/Post/" + fileName }, JsonRequestBehavior.AllowGet); 

,但问题没有解决!

我发现了这个问题。

必由之路写道

return Json(new { link = new UrlHelper(Request.RequestContext).Content("~/img/Post/" + fileName) }, JsonRequestBehavior.AllowGet);