標籤:xmlns min dir hot rect dex frame erro sse
原帖:http://user.qzone.qq.com/369175376/infocenter?ptlang=2052 第一步:先到http://ueditor.baidu.com/website/download.html去下載
第二步:把下載的檔案改成ueditor名稱,添加到Content檔案夾裡面
第三步:在ueditor檔案夾下面的net檔案夾建立一個upload檔案夾裝上傳的圖片
第四步:找到net檔案夾裡面的config.json檔案,在找到所有的
/* 圖片訪問路徑首碼 */
然後在前面的途徑加上:/Content/
其它配置圖片訪問路徑首碼,以此類推,因為我們把ueditor檔案夾放在了Content檔案夾下面
第五步:建立一個Home控制器,點Index右鍵產生視圖
在視圖裡面添加:
<script src="~/Content/ueditor/ueditor.config.js"></script><script src="~/Content/ueditor/ueditor.all.js"></script><link href="~/Content/ueditor/themes/iframe.css" rel="stylesheet" /><script src="~/Content/ueditor/lang/zh-cn/zh-cn.js"></script>
注意先後順序,不要顛倒了! <script type="text/javascript"> var editor = new baidu.editor.ui.Editor({ UEDITOR_HOME_URL: ‘/Content/ueditor/‘,//配置編輯器路徑 iframeCssUrl: ‘/Content/ueditor/themes/iframe.css‘,//樣式路徑 initialContent: ‘歡迎使用ueditor‘,//初始化編輯器內容 autoHeightEnabled: true,//高度自動成長 minFrameHeight: 500//最小高度 }); editor.render(‘editor‘); </script>@using(Html.BeginForm("Index","Home",FormMethod.Post)){ <textarea id="editor" name="editor"> </textarea> <input type="submit" value="提交" />}
這個是Index頁面裡面的內容
第六步:在控制器裡面在添加一個httppost的Index方法
[HttpPost] [ValidateInput(false)] public ActionResult Index(FormCollection fc) { var content = fc["editor"]; return View(); }
注意: [ValidateInput(false)]這是解決一直報安全問題的辦法
第七步:產生會報錯,在ueditor裡面net檔案的bin裡面的Newtonsoft.Json無法拷貝到當前項目裡面的bin目錄裡面,那是因為ueditor的net檔案裡面的Newtonsoft.Json的版本要高於項目裡面的版本,把項目裡面的Newtonsoft.Json引用刪除掉,在引用ueditor裡面net檔案的bin裡面的Newtonsoft.Json的dll檔案
第八步:在Web.config裡面找到 <runtime>節點
在它下面的<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
節點裡面添加
<dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" /> <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> </dependentAssembly>
如上節點,就可以解決 Newtonsoft.Json無法引用的問題
以上步驟都作完成,就可以實現富文本並且可以上傳圖片了!
ASP.NET MVC4 使用UEditor富文本