Asp.net-Mvc

當站點部署在 IIS 上時 CKEditor 不工作

  • March 30, 2016

我在我的 MVC 應用程序中使用 CKEditor。

我正在使用“ckeditor-full”(版本 4.4.2)包。

我在包中包含了“ckeditor\adapters\jquery.js”和“ckeditor\ckeditor.js”文件,並在 _Layout.cshtml 文件中引用了這些包。

@Scripts.Render("~/bundles/Scripts/ckeditor")
@Scripts.Render("~/bundles/Scripts/ckeditor/adapters")

“Scripts/ckeditor”文件夾包含隨包下載的所有 352 個文件。

以下是 config.js 文件(位於“Scripts/ckeditor”文件夾中。

CKEDITOR.editorConfig = function( config )
{
   // Define changes to default configuration here. For example:
   config.toolbar = 'Custom';
   config.disableNativeSpellChecker = false;
   config.browserContextMenuOnCtrl = true;
   config.forcePasteAsPlainText = true;

   config.toolbar_Custom = [
       { name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike', '-', 'RemoveFormat'] },
       { name: 'paste', items: ['PasteText'] },
       { name: 'links', items: ['Link', 'Unlink'] }
   ];
};

以下是我為 textarea 顯示 CKEditor 的方式:

$("#idBodyText").ckeditor();

問題是,它在本地執行良好,如果在本地 IIS 上以調試模式執行。但是,在具有發布配置的 IIS 上部署時,它不會顯示 CKEditor。

知道可能是什麼原因,以及如何解決這個問題?

對此非常感謝任何幫助。

謝謝

作為一項解決方案,事實證明,在載入捆綁包之前,我必須在視圖中包含以下行 -

<script type="text/javascript">
   CKEDITOR_BASEPATH = "@Url.Content("~/Scripts/ckeditor/")";
</script>

檢查您的捆綁包是如何生成的stylesheet以及scripts頁面源中的連結:

@Scripts.Render("~/bundles/Scripts/ckeditor")
@Scripts.Render("~/bundles/Scripts/ckeditor/adapters")

這可能是一個問題- 在這種HTTP Error 404 - File or Directory not found情況403.2 - Read access forbidden.下,您應該檢查文件是否正確儲存在伺服器上(在正確的位置)並檢查該文件夾的權限。

Firebug也有助於調試。我強烈推薦使用它。

引用自:https://stackoverflow.com/questions/24503284