ASP .NET MVC中的TinyMCE Spellchecker

时间:2009-07-13 23:22:30

标签: asp.net asp.net-mvc tinymce spell-checking

我遵循了here所描述的教程,以使TinyMCE Spellchecker在Webforms应用程序上运行。但我尝试在MVC项目上做同样的事情,每次尝试使用拼写检查器时都会出错。

我想知道为了在ASP .NET MVC项目上发表这个词,我需要做些哪些更改或调整。

我得到的错误如下:

[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)

2 个答案:

答案 0 :(得分:5)

有点难以知道问题是什么而不知道你得到的错误是什么,但我猜它是因为你需要忽略你的MVC中的拼写检查器的路径。通过向MVC路由定义添加类似的内容来实现此目的:

//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}");

如果没有上述内容,它会将拼写检查请求URL(TinyMCE.ashx...)解释为MVC路由&尝试找到匹配的控制器(&明显失败)。

如果这不是问题,我建议发布一些有关您所看到的具体错误的更多信息。

答案 1 :(得分:4)

我对MVC很新(一年多一点)并且对我的解决方案中的特定页面进行拼写检查非常感兴趣。以上选项可能适用于某些人,但对我不起作用(我不是很耐心,并且诚实地不想忽略任何路由,或修改我的配置的system.web部分的东西只有5%的解决方案消费者会使用,所以我没有花很多时间在这些选项上。)

所以:

  1. 我将Moxiecode.TinyMCE.dll文件复制到我项目中的目录中,因此未来的贡献者将拥有该dll而无需搜索谷歌。
  2. 我在上面的项目中添加了对上面dll的引用。
  3. 我创建了一个名为SpellCheckController.cs的新控制器,其中包含以下内容:

    public void CheckSpelling()
    {
        SpellCheckerModule spellChecker = new SpellCheckerModule();
        spellChecker.ProcessRequest(System.Web.HttpContext.Current);
    }
    
  4. (不要忘记使用Moxiecode.TinyMCE.SpellChecker;)

    并在我的视图中仅在TinyMCE的设置选项中引用了这样的控制器:

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

    我没有忽略任何路线。我没有添加另一个httphandler到我假设是一个非常长的.net处理程序列表,拼写检查现在适用于我。

    我也有能力在不改变太多的情况下使用不同的东西(假设我弄清楚TinyMCE的拼写检查器在http上下文中做了什么。

    P.S。 Stack Overflow的富文本编辑器似乎没有拼写检查功能,因此上述拼写没有保证:)