Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 781
Nirman Avatar asked Jul 01 '14 05:07

Nirman


2 Answers

Check how your bundles generated stylesheet and scripts links in page source:

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

It could be a problem with HTTP Error 404 - File or Directory not found or 403.2 - Read access forbidden. - in that case, you should check if files are properly store on serwer (in correct location) and check permissions for that folder.

Also helpful for debugging will be Firebug. I strongly recommend it to use.

like image 41
whoah Avatar answered Oct 01 '22 00:10

whoah


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>
like image 194
Nirman Avatar answered Oct 01 '22 02:10

Nirman