Search code examples
asp.net-mvcasp.net-mvc-4iisckeditorbundle

CKEditor not working when site is deployed on IIS


I am using CKEditor in my MVC application.

I am using "ckeditor-full" (Version 4.4.2) package.

I have included "ckeditor\adapters\jquery.js", and "ckeditor\ckeditor.js" files in the bundle and referenced those bundles in the _Layout.cshtml file.

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

"Scripts/ckeditor" folder contains all 352 files that were downloaded with the package.

Following is config.js file (which is residing in "Scripts/ckeditor" folder.

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'] }
    ];
};

Following is how I display CKEditor for textarea:

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

The issue is that, it works fine locally and if running on local IIS in debug mode. However, it doesn't display CKEditor when deployed on IIS with release config.

Any idea what could be the possible reason, and how to resolve this?

Any help on this much appreciated.

Thanks


Solution

  • As a resolution, it turned out that, I had to include following line in my view before loading the bundles -

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