'NullReferenceException with Ckeditor 5 and ASP.NET MVC bundle error?
To isolate any problems so I can reproduce the issue, I started with a brand new project in VS 2017 with the ASP.NET MVC Template (.NET Framework 4.6.1).
I added the latest ckeditor5 to /Scripts/ckeditor5/ckeditor.js
In BundleConfig.cs, I added this:
bundles.Add(new ScriptBundle("~/bundles/ckeditor").Include(
"~/Scripts/ckeditor5/ckeditor.js"));
In _layout.cshtml, I have this:
@Scripts.Render("~/bundles/ckeditor")
When I run the application, it gives "System.NullReferenceException" error. It seems Microsoft Ajax parse doesn't like ckeditor5??
at Microsoft.Ajax.Utilities.JSParser.ParseObjectLiteralProperty(Boolean isBindingPattern)\r\n at Microsoft.Ajax.Utilities.JSParser.ParseObjectLiteral(Boolean isBindingPattern)\r\n at Microsoft.Ajax.Utilities.JSParser.ParseLeftHandSideExpression(Boolean isMinus)\r\n at Microsoft.Ajax.Utilities.JSParser.ParseUnaryExpression(Boolean& isLeftHandSideExpr, Boolean isMinus)\r\n at Microsoft.Ajax.Utilities.JSParser.ParseVarDecl(JSToken inToken)\r\n
at Microsoft.Ajax.Utilities.JSParser.ParseVariableStatement()\r\n at Microsoft.Ajax.Utilities.JSParser.ParseFunctionBody(Block body)\r\n
at Microsoft.Ajax.Utilities.JSParser.ParseFunction(FunctionType functionType, Context fncCtx)\r\n at Microsoft.Ajax.Utilities.JSParser.ParseLeftHandSideExpression(Boolean isMinus)\r\n at Microsoft.Ajax.Utilities.JSParser.ParseUnaryExpression(Boolean& isLeftHandSideExpr, Boolean isMinus)\r\n at Microsoft.Ajax.Utilities.JSParser.ParseArrayLiteral(Boolean isBindingPattern)\r\n at
If I forget about Bundle and I hard code the path like this on _Layout.cshtml, it worked:
<script src="~/Scripts/ckeditor5/ckeditor.js"></script>
Any idea how to make bundle works for ckeditor5?
Solution 1:[1]
This issue most probably has to do with the ScriptBundle trying to Minify a file which was already minified. Which in the case of the Ckeditor5 breaks.
The fix was to add .min to the file extension before the .js.
This fixed the issue for me.
Solution 2:[2]
You don’t have to use the extension file in the name of ScriptBundle.
Not like this:
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js"));
Do it like this:
On BundleConfig.cs:
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap"));
On file.cshtml:
@Scripts.Render("~/bundles/bootstrap")
I found this on this page: https://www.it-swarm-es.com/es/asp.net-mvc/mvc-bundling-no-se-pudo-cargar-el-recurso/1040501977/
Solution 3:[3]
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include("~/Scripts/bootstrap"));
After using this Top bar Disappeared from Homepage like bootstrap does not working properly
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sam munkis |
| Solution 2 | MiguelCR |
| Solution 3 | pat8719 |
