Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TinyMCE Spellchecker in ASP .NET MVC

I followed the tutorial described here, in order to make the TinyMCE Spellchecker work on a Webforms application. But I tried to do the very same thing on a MVC project and keep getting errors every time I try to use the spellchecker.

I'd like to know what changes or adjustments I need to make in order to make this word on an ASP .NET MVC project.

The error I'm getting is the following:

[HttpException]: The controller for path '/TinyMCE.ashx' could not be found or it does not implement
 IController.
   at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(Type controllerType)
   at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String
 controllerName)
   at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext)
   at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext)
   at System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute
()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
like image 454
Raúl Roa Avatar asked Dec 29 '22 19:12

Raúl Roa


2 Answers

Well its a bit hard to know what the problem is without knowing what the error you're getting is, but I'm guessing that its because you need to ignore the route to the spell checker in your MVC. Do this by adding something like this to your MVC route definitions:

//ignore just the TinyMCE spell checker service:
routes.IgnoreRoute("TinyMCE.ashx");
//or if you want to be more general & ignore all ashx's:
routes.IgnoreRoute("{resource}.ashx{*pathInfo}");

Without the above it would be interpreting the spellcheck request url (TinyMCE.ashx...) as an MVC route & try to find a matching Controller (& obviously fail).

If that's not the issue, I'd suggest posting some more info about the specific error you're seeing.

like image 174
Alconja Avatar answered Jan 17 '23 23:01

Alconja


I'm pretty new to MVC (a little over a year) and was pretty interested in spell check for a specific page in my solution. The above options may work for some folks, but didn't work for me (I'm not very patient, and in all honesty didn't want to ignore any routes, or modify my the system.web section of my config for something that only 5% of my solution consumers are going to use, so I didn't spend a whole lot of time on those options).

So:

  1. I copied the Moxiecode.TinyMCE.dll file to a directory in my project so future contributors will have the dll without having to search google.
  2. I added a reference to the above dll to my project.
  3. I created a new controller called SpellCheckController.cs that contains the following:

    public void CheckSpelling()
    {
        SpellCheckerModule spellChecker = new SpellCheckerModule();
        spellChecker.ProcessRequest(System.Web.HttpContext.Current);
    }
    

(don't forget the using Moxiecode.TinyMCE.SpellChecker;)

and just referenced the controller like this in the setup options for TinyMCE in my view:

spellchecker_rpc_url: "@Url.Action("CheckSpelling","SpellCheck")/?module=SpellChecker"

I haven't ignored any routes. I haven't added another httphandler to the what I am assuming is a pretty long list of handlers for .net, and spell check works for me now.

I also have the ability to go with something different without changing too much (assuming I figure out what TinyMCE's spellchecker is doing with the http context.

P.S. Stack Overflow's rich text editor doesn't seem to have a spell check feature, so there are no guaranties on the above spelling :)

like image 20
Brian Avatar answered Jan 18 '23 00:01

Brian