Recently I’ve been working on a website which is built in C sharp using the .NET framework (version 2) and running on IIS. This is a fairly different experience to my usual linux/ apache/ php/ mysql and actionscript setup but it’s been interesting and rewarding. I’m planning a series of posts documenting things that I’ve found out and like or dislike about this environment but for now just a quick one about how to get the spell checker for TinyMCE working…
TinyMCE is “a platform independent web based Javascript HTML WYSIWYG editor control” which is very popular on the web (in fact I am using it to create this post in wordpress!). It comes with heaps of functionality and plugins including a spellchecker. As you’ll see at that link though, the spell checker requires PHP on the serverside… Or does it?
If you look on the TinyMCE download page you will see that there is a .NET package available. I was curious about what this was, especially when I looked through the zip and found that it contained a SpellChecker folder. Looking at the code it turns out that this is the alternative of the PHP code necessary for implementing the spell checker – it accepts the AJAX request from a TinyMCE instance, sends it off to Google’s spell checking web service and sends the relevant results back in the AJAX response. Yay! Now I needed to find out how to use it – for some unknown reason this all seems to be undocumented and google wasn’t bringing back any answers either.
Looking through the c# code, I found that the .NET package is implemented as an IHttpHandler. Once I knew that it was pretty easy to figure out how to configure IIS to use the code. Basically you need to drop the Moxiecode.TinyMCE.dll from the .NET package into the bin folder of your website. Then open your web.config file and find the httpHandlers node inside the system.web node and add the following line in:
This tells IIS that all calls to /TinyMCEHandler.aspx should infact be handled by the Moxiecode.TinyMCE.Web.HttpHandler class in the Moxiecode.TinyMCE assembly. The validate=”false” means that IIS won’t check if this dll and class can be found unless you actually request that page (this is useful if you have seperate applications mapped to virtual directories below this web.config as it will prevent those applications throwing errors because they can’t find the dll)
Now you just have to set up your TinyMCE instances to include a spell checker button and to know the correct place to look for the serverside script. Here is how we instantiate TinyMCE:
mode : "textareas",
theme : "advanced",
plugins : "paste, spellchecker",
theme_advanced_buttons1 : "bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,undo,redo,separator,link,unlink,separator,cut,copy,paste,pastetext,pasteword,separator,forecolor,backcolor,separator,code,separator,spellchecker",
spellchecker_rpc_url: "/TinyMCEHandler.aspx?module=SpellChecker"
});
The important things are:
- Added “spellchecker” to the plugins list.
- Added a “spellchecker” button to the buttons list.
- Added the spellchecker_rpc_url which tells TinyMCE where to find the serverside script.
69 Comments, Comment or Ping
Do I need the TinyMCEHandler.aspx? Am I missing something?
February 24th, 2009
That file doesn't actually exist - you create it httpHandler rule in the web.config and then you point to it from the javascript... You can change the name to anything you like as long as you change it in both places, I just picked a name that would make some sort of sense when it shows up in the server logs...
February 24th, 2009
Thanks Kelvin and Lance for showing the way to it, the question asked by lance and the answer by you helped me a lot....
Cheers
May 7th, 2009
These are good instructions, you helped a lot.
May 27th, 2009
Great article! I have an ASP.NET MVC app and I am receiving an error, "Error: No Response". Any idea how to resolve this error?
I would appreciate the help.
Thanks!
May 30th, 2009
Great article thanks. It didn't work initially for me running on IIS7.
I had put the following in the 'handlers' section (not httphandler) to get it to work.
I actually did it via the IIS 7 management console, and it added the above line for me.
June 1st, 2009
Hi Guys,
@Rich - sorry, I don't know how to resolve that error. What version of ISS are you using? Maybe Justin's comment will help if you are using IIS7...
@Justin - thanks for the update. That sounds like it will be really useful information for people using IIS7. Unfortunately the code didn't make it through my blogs comment system. Can you repost but change the < and > to their HTML entity equivilents (& l t ; and & g t ; without the spaces)?
Thanks,
Kelvin :)
June 1st, 2009
<handlers>
<add name="TinyMCE spell checker" path="TinyMCEHandler.aspx" verb="*" type="Moxiecode.TinyMCE.Web.HttpHandler" resourceType="Unspecified" preCondition="integratedMode" />
June 2nd, 2009
Great - thanks for that Justin. Hopefully that will help out anyone else using IIS7 :)
June 4th, 2009
Kevin and Rich,
I found the solution to Rich's MVC related problem (I think). It has to do with how routing is set up. Add the following line to the RegisterRoutes method in Global.asax:
routes.IgnoreRoute("TinyMCEHandler.aspx");
- Chris
June 8th, 2009
Awesome - thanks Chris :)
June 12th, 2009
When using Google's spell check service from a corporate intranet should there be some degree of concern with transmitting content to be spell checked? Quite literally, isn't each word you type validated by Google's service, essentially passing the entire content of your message to Google? If this round-trip process is encrypted I would see less concern, otherwise for a company that may have sensitive information isn't this an issue?
Thanks,
Greg
June 19th, 2009
Hi Greg,
Yes - I guess there would be a concern with using the spell checker service on "secret" content. In this situation you would want to use a spell checking solution which was hosted on your own servers. I'm not sure if there is a way to do this with TinyMCE as I didn't need to - the content that was being spell checked in my case was the content for the front end of a public website...
Cheers,
Kelvin :)
June 19th, 2009
Thank you for the prompt response. I just wanted to present this as a concern when deciding what solution we should use. I have several internal communication templates I maintain and many are requesting some kind of spell check. Communications are sent on an almost daily basis and it's generally not public information, not that many would care. It's not like our communications contain the secret formula of CocaCola or anything. Paranoid? Perhaps. Anyway, we're migrating to a new server soon which may allow us more liberties with installing 3rd party software, so hopefully then we can figure something out then. In the meantime I'll just recommend that everyone use Firefox (not such a bad thing). Thanks again!!
June 19th, 2009
I followed your instructions, thanks! However, when i click on the spell check button in tinyMCE, it throws an error saying "not found".
Screenshot: http://screencast.com/t/jxHTA6UI4X
I have the web.config set up correctly, copied straight from your example. (I am using IIS6) I added the line to the editor init as you specified (copied and pasted). The spell check button appears in the editor.
I am trying to use the regular TinyMCE package instead of the .NET version. I downloaded the .NET package, but I honestly wasn't sure how to handle all the extra files. I didn't think simply copying and pasting them in would work since it's a class library. I put the dll into the bin and referenced it, made the web.config changes that are in the included sample, and I still have no luck.
Any suggestions? are you using the "regular" tinyMCE package in this sample? or did you add the class library to your project?
July 15th, 2009
Hi Lindsay,
It sounds like you did everything right so I'm not sure why it's not working... I downloaded the .net package but all I used from it was the Moxiecode.TinyMCE.dll file. I put that in my website bin directory and then made the changes to the web config as described... You could try debugging by using Firebug in Firefox with the network panel enabled and seeing what URL is requested when you press the spellcheck button. It should be /TinyMCEHandler.aspx and this should be what your web.config is making point to the dll... The only other thing I can think of is whether or not your webconfig in the root directory of your web server?
Hope that helps,
Kelvin :)
July 15th, 2009
Could you possibly zip up your entire .sln and make that available for download on your site? Or email it to me? (Sorry, I'm assuming you have a simple sample available...)
July 15th, 2009
Hi Lindsay,
Sorry - I don't have a simple example (or even access to the live example). If you can provide an link to your site I can try to have a quick look, otherwise you can try my debugging suggestions above?
July 15th, 2009
I should've thought of this sooner, but I didn't. I had to make my path to the TinyMCE file a virtual link since I'm still in development mode. So instead of
spellchecker_rpc_url: "/TinyMCEHandler.aspx?module=SpellChecker"
i had to make it
spellchecker_rpc_url: '<%=Page.ResolveUrl("~/TinyMCEHandler.aspx?module=SpellChecker")%>'
July 15th, 2009
PS - thanks for your help anyway =)
July 15th, 2009
I'm not sure I've ever invested that little time in code for that much benefit. Our dept. is going to get a bunch of undeserved kuddos :)
July 16th, 2009
This is mostly working good for us. We have experienced problems when using spell check and selecting "ignore all". The browser will lock up.
I was able to duplicate the problem but it does work sometimes.
Has anyone else had this problem?
July 29th, 2009
My last comment about having problems with the browser locking up when using "ignore all" in the spellchecker may not matter soon. It looks like google will drop the SOAP Search API, which TinyMCE is apparently using, Aug 31st 2009.
http://googleajaxsearchapi.blogspot.com/search/label/SOAP%20Search%20API
July 29th, 2009
Hi Lance,
I haven't seen the problem you mentioned but I haven't really used "Ignore all". It sounds like it might be a JS bug rather than related to the backend though - can you reproduce it on TinyMCE's examples? Or you could make sure you are using the latest TinyMCE code and ask in their forums.
Re. the other point, I don't think that the spellchecker uses the SOAP search API. From a quick look in the sourcecode I think it instead piggybacks on a non-public API used by the google toolbar (like in this JAVA example: http://www.gmacker.com/web/content/tutorial/googlespellchecker/googlespellchecker.htm ).
I also came across this post though which may end up being a more robust .net solution (although they don't seem to provide their sourcecode):
http://channel9.msdn.com/posts/C9Team/Spelling-Code-Blocks-and-Twitter-on-Channel-9/
(via http://blog.moxiecode.com/2009/06/11/spellchecker-using-bing-api/ ).
Hope that helps,
Kelvin :)
July 30th, 2009
Thanks for the reply Kelvin.
I thought is was using the search API since that is where the link in your article pointed me.
It works in my browser after the first couple of tries where it locked up. It didn't seem to be a JS error. It just hung for a couple of minutes and the cpu time for IE went to 80% like it was trying to install something before I killed the browser window. After that it works fine for me now.
It still fails for another user when using IE8? and Vista. I am using IE7.
Thanks for the links. It looks like there are other options to investigate if we still have problems.
Thanks for your assistance!
July 30th, 2009
Hi, i used your example and it works, but i have the problem that it last too much for cheking the results.
Maybe i dont have something installed, i have:
TinyMCe installed, the dll in the bin folder and the configurations in my page. I see Spellcheck uses JSON this cames weith TINYMCE or i hace to install it apart?
Thanks in advance.
Leviatas
August 20th, 2009
Hi Leviatas,
Sorry - I don't understand what you mean by "it last too much". What is happening? Is the spell checker working or not?
Cheers,
Kelvin :)
August 22nd, 2009
Hi Kelvin and Lance,
I am using TINYMCE for a couple or days and I am organizing my folders, and I have the same question than Lance about TinyMCEHandler.aspx. What is the code of that page?
is an empty page?. I need to use TINYMCE in differents pages, Does i change?
Another Question I have is if I have to replace the Directory SpellChecker that came with tinymce with this new Directory?
September 3rd, 2009
Thanks, it saved my time.shake and bake
November 20th, 2009
Thank you kindly for taking the time to document this. Works like a charm! Appreciate the help!
December 31st, 2009
Hi Kelvin,
Need help with TinyMCEHandler.aspx. What is in TinyMCEHandler.aspx?
I am still new to .net, could not make enough sense from your your earlier post "…you create it httpHandler rule in the web.config and then you point to it from the javascript…" .
Please help, THANKS!
Jocu
January 24th, 2010
Hi Diego & Jocu,
See my reply above to the first comment on this post. The TinyMCEHandler.aspx file doesn't exist - it is the path that you set in Web.config. That means that all requests to that path are actually routed to the Moxiecode.TinyMCE.Web.HttpHandler inside the TinyMCE dll - and that deals with sending the correct response back to the javascript.
Hope that helps,
Kelvin :)
January 24th, 2010
Kelvin, thanks for the quick response and making that clear. I had misunderstood "doesn't exist" as meaning that it needed to be created...
January 24th, 2010
Hello,
Scratching my head with this runtime error when I click on spellcheck btn (using IIS7 with the my web.config section is also below)
[HttpException (0x80004005): Could not load type [Moxiecode.TinyMCE.Web.HttpHandler'.]
System.Web.Compilation.BuildManager.GetType
(String typeName, Boolean throwOnError, Boolean ignoreCase) +8827093
System.Web.Configuration.HandlerFactoryCache.GetHandlerType(String type) +21
System.Web.Configuration.HandlerFactoryCache..ctor(String type) +19
System.Web.HttpApplication.GetFactory(String type) +78
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +229
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155 ]
---web.config---
January 24th, 2010
I haven't tested on IIS7 but did you read the comment from Justin above? Maybe that will help you?
January 24th, 2010
Kelvin, thank you, thank you for the blog. My Jaw dropped when the spellchecker worked this morning! I totally expected to struggle with it for another day or so!
I also used IIS 7 management console but had to manually remove the auto generated scriptProcessor=" \bin\Moxiecode.TinyMCE.dll" part from the section in web.config.
January 25th, 2010
Thank you, thank you. Works perfectly. =)
February 4th, 2010
Hi very nice post... it worked nicely...
June 18th, 2010
Thanks this is excellent stuff.
July 2nd, 2010
Has anyone gotten this to work in an ASP.NET MVC2 web app (IIS7)?
here is my init call:
tinyMCE.init({
mode : 'exact',
elements : 'message',
theme : 'advanced',
skin : 'o2k7',
skin_variant: 'silver',
plugins: 'spellchecker',
// Theme options
theme_advanced_buttons1: 'spellchecker,fontselect,fontsizeselect,|,bold,italic,underline,strikethrough,|,backcolor,forecolor,|,bullist,numlist,outdent,indent,|,justifyleft,justifycenter,justifyright,justifyfull,|,link,unlink,|,charmap',
theme_advanced_buttons2: '',
theme_advanced_buttons3: '',
theme_advanced_toolbar_location : 'top',
theme_advanced_toolbar_align : 'left',
theme_advanced_statusbar_location : 'bottom',
theme_advanced_resizing : true,
spellchecker_rpc_url: '/TinyMCEHandler.aspx?module=SpellChecker'
});
here is the line in the web.config:
also, I have this in the RegisterRoutes function in the Global.asax.cs file:
routes.IgnoreRoute("TinyMCEHandler.aspx");
here is the error message that I get once I click on the spell check button:
"Error response:
null
null
null
null
[HttpException]: The file '/TinyMCEHandler.aspx' does not exist.
at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)
at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
"
I just can't get this thing to work!!! Any ideas?
thanks!!!
it's just not working for me
August 1st, 2010
It didn't post my web.config settings, though it's what Justin posted above.
configuration -> system.webServer -> handlers -> add...
August 1st, 2010
Sorry Daniel, I'm afraid I don't know what is going wrong for you. I haven't tried to get this working on IIS at all... Maybe googling generic information about registering HTTP Handlers from a dll assembly on IIS 7 with MVC2 will come up with an answer? Or maybe somebody else who commented here has more experience with IIS7?
August 2nd, 2010
I figured it out. Again, I'm using a MVC2 application (IIS7)
I had Justin's suggestion in the Views/web.config file. So then I tried Kelvin's way in that file. Still didn't work. So I ripped it out of the Views/web.config file and pushed it to the top level web.config file. I had to add the httpHandlers module under the system.web section, though it works now! I even tried Justin's way in the top level web.config and it didn't work.
It seems that the MVC2 apps need the IIS6 style config.
One thing to note here... this worked when running it out of VS2010. Though if I assign a website to the code, I still can't get it to work :(
It must be some weird IIS setting. The good news is it works! Just need to figure out the config.
August 2nd, 2010
Glad you got to the bottom of it... It makes sense that it needs to be in the top level web.config.
Re. needing IIS6 style coding, are you using the "classic" Managed PipeLine Mode (as opposed to "integrated")? If so then it would make sense...
Good luck figuring the rest out :)
August 2nd, 2010
Hmm... I'm not sure what VS2010 is doing. I'm assuming it's Integrated.
August 3rd, 2010
can you please tell me where to put this code?
tinyMCE.init({
mode : "textareas",
theme : "advanced",
plugins : "paste, spellchecker",
theme_advanced_buttons1 : "bold,italic,underline,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,undo,redo,separator,link,unlink,separator,cut,copy,paste,pastetext,pasteword,separator,forecolor,backcolor,separator,code,separator,spellchecker",
spellchecker_rpc_url: "/TinyMCEHandler.aspx?module=SpellChecker"
});
i am sorry but i really was not able to get the idea ...
August 13th, 2010
Hi Fakhre,
You would place that in a javascript file which is included in your pages (or in a script tag in the head of your page. It is the same as the normal TinyMCE initialisation except it also passes the spellchecker_rpc_url parameter...
Hope it helps,
Kelvin :)
August 16th, 2010
Ok, thanks it works, really good.
Now i want to remove the toggle button with spellchecker button for languae selection, i really appreciate if you guide me to remove that button.
August 16th, 2010
That is more of a general TinyMCE question - please check out the TinyMCE documentation [ http://wiki.moxiecode.com/index.php/TinyMCE:Configuration ] or forums [ http://tinymce.moxiecode.com/punbb/ ]
August 17th, 2010
this spell checker having little bug or so, when we write some string like 'aaa' and then check the spell it returns good, but if i do start typing like 'aaa bbb' and check the spell then the space between these two gone away and string looks like this 'aaabbb'
can you please fix this or guide me how to fix it?
August 23rd, 2010
I'm afraid I don't know why that is... You could ask on the TinyMCE forums as I don't think this question is specific to the .net version of the spellchecker interface...
August 23rd, 2010
ok thanks, but can you please confirm me that you are getting kind of problem at your end too or not. so it will help me to understand that scope.
August 23rd, 2010
This is the greatest write-up! Not a single problem on the first try. Works great!!!
October 28th, 2010
I am tryingt o get spellchecker (.net package) to work on the webserver and no luck so far....
I tried all the intructions in your post and some in the comments section such as add to direct the spellcheck call to the code in Moxicode.TinyMCE. and I got the Spellchecker to work wonderfully on my development machine (Windows 7, VS 2010) but i cant get it to work on the web server which is (Win 2003, IIS6).
I read elsewhere there the google webservice call requires SSL/HTTPs enabled...is this true. Has someone had any luck with or did you have to enable SSL to get it going on a web server? Please help...i have step 2 full days on this and still havent found a workable solution.
P.S. using the PHP spellchecker is not an option from where i come...so i have to get the webservice going...
November 9th, 2010
MENITA
I have it working without SSL on the server so I don't that that is your issue.
The server I am using it on an intranet only and some people in the company have trouble with spell check locking up the browser but only from one office. The other offices work fine so it is some security setup at that office or something for me.
November 9th, 2010
Lance - Did you have to do anything different on the server? I cant get the application on the server to throw an error message...I had fiddler running as I was trying the website with spellcheck and i got the gray styling over the textarea control and the small circle with animation - as if the application was attempting to do something. But this went on indefinetly and i did not see any connection to http://www.google.com port 443 on fiddler....if I could get to some error message that would help to get a start on this....they i think my application is not even able to establich a connection to google web service...
Thought?
November 9th, 2010
I have mine setup like the instructions specify. The spellchecker url on the pages is different because of the path I have setup.
spellchecker_rpc_url: "../TinyMCEHandler.aspx?module=SpellChecker"
November 9th, 2010
I can't tell you anything that isn't in the article I'm afraid Menita. And it's been a long time since I looked at this. However, I believe that it is the server which communicates with the google API, not your computer directly (the server is in effect a proxy). So you wouldn't see anything in Fiddler on your computer...
Maybe there is a firewall preventing outgoing https calls from the server to google?
November 9th, 2010
Lance - what path should "../TinyMCEHandler.aspx?module=SpellChecker"
resolve to?
Is it the same level as the webconfig file or the scripts folder?
November 10th, 2010
Mine is pointing to the site root where the web.config file is.
November 10th, 2010
Thanks! that did it.
Pheww
November 10th, 2010
Though i have followed all stpes ,i am getting "Error Response" error after clicking on spellchecker in editor.
how to resolve this error ?
Is there any difference in making this work in asp.net web app and asp.net mvc web app ?
Thanks
November 25th, 2010
Thanks for this it helped me a lot...
also thanks to lindsay as i also was using it in development mode...
December 1st, 2010
I'm using blog egine .net, that uses tiny mce as default editor.
my boss asks me about a spellchecker and i try to implement like on this post, and it works fine, but is too fast. about 5 seconds and all underlines disappears, or if i'm making a correction, the menu hides in less than 3 seconds.
when a visit the full example on tinymce website, this not happening.
(see http://tinymce.moxiecode.com/examples/full.php)
but the example uses a php interface for de google suggestions.
anyone having this problem? any ideas?
thanks
December 10th, 2010
FANTASTIC!!! Thank you Kevin so much.
Within literally 2 minutes I had the spell checker integrated into Tiny MCE which itself is integrated into Dojo.
It worked first time. High five!
February 25th, 2011
Has anyone thought to make this work against a Div instead of a TextArea?
June 30th, 2011
Kelvin, this is amazing. IT JUST WORKS!!!! I'd set aside a day and a half to get a non-PHP spell checker set up for tinyMCE on IIS, and thanks to this blog post, I'm done in 20 minutes.
Thank you so much!
October 18th, 2011
You could not be more right..
November 10th, 2011
I have set up all for( tinymce on 2008 web server with ASP.NET 3.5 )explicitly as presented here and when I click on the spellchecker (abc) button IE 9 just hangs and then IE9 / Windows 7 Client responds with a do you want to stop the script message. Has anyone experienced this and if so, do you have a resolution for it. TIA
December 25th, 2011
Reply to “Using spell checker for TinyMCE with .NET on IIS”