# Building a Spell Checking Web API in ASP.NET Core

> TX Spell .NET provides a fully-featured spell checking interface and integration when used with TX Text Control editors. But it can be used without a UI as a spell checking engine as well. This sample shows how to create a spell checking Web API in ASP.NET Core.

- **Author:** Bjoern Meyer
- **Published:** 2020-05-15
- **Modified:** 2026-07-17
- **Description:** TX Spell .NET provides a fully-featured spell checking interface and integration when used with TX Text Control editors. This sample shows how to create a spell checking Web API in ASP.NET Core.
- **3 min read** (535 words)
- **Tags:**
  - ASP.NET
  - ASP.NET Core
  - TX Spell
  - Web API
  - Windows Forms
- **Web URL:** https://www.textcontrol.com/blog/2020/05/15/building-a-spell-checking-web-api-in-aspnet-core/
- **LLMs URL:** https://www.textcontrol.com/blog/2020/05/15/building-a-spell-checking-web-api-in-aspnet-core/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2020/05/15/building-a-spell-checking-web-api-in-aspnet-core/llms-full.txt
- **GitHub Repository:** https://github.com/TextControl/TXTextControl.Core.Spell.WebAPI

---

TX Spell .NET is a very powerful spell checking engine with a tight integration into the document editors from Text Control including ASP.NET, Angular and Windows Forms. It provides fully-featured UI elements including dialog boxes and context menus when connected to a Text Control instance.

### Non-Visual Spell Engine

But the product also includes the non-visual component TXSpell that can be used for background processing. This sample shows how to use this class to create a spell checking Web API using ASP.NET Core.

### Implementing the Web API Controller

The sample implements the Web API controller *SpellController*:

```
[Route("api/[controller]")]
[ApiController]
public class SpellController : ControllerBase
{

}
```

This controller implements 4 endpoints:

- Check
- CreateSuggestions
- CreateSynonyms
- DetectLanguageScopes

The following code shows the implementation of the *Check* method that accepts the *Text* to be checked and an optional language identifier:

```
[HttpGet]
[Route("Check")]
public List<IncorrectWordModel> Check(string text, string language = "en_US")
{
    if (text == null)
        return null;

    // create a new spell checking engine
    TXTextControl.Proofing.TXSpell spell = new TXTextControl.Proofing.TXSpell();
    spell.Create();

    TXTextControl.Proofing.OpenOfficeDictionary dict = 
        new OpenOfficeDictionary(@"Dictionaries\en_US.dic");
    spell.Dictionaries.Add(dict);

    spell.Check(text, new System.Globalization.CultureInfo(language));

    List<IncorrectWordModel> lIncorrectWords = new List<IncorrectWordModel>();

    var incorrectWords = spell.IncorrectWords;

    if (incorrectWords == null)
        return null;

    foreach (IncorrectWord word in incorrectWords)
    {
        lIncorrectWords.Add(new IncorrectWordModel()
        {
            Text = word.Text,
            Index = word.Index,
            IsDuplicate = word.IsDuplicate,
            Length = word.Length,
            Start = word.Start
        });
    }

    return lIncorrectWords;
}
```

In the method *Check*, a new instance of the spell checker is created and a dictionary is loaded and added to the available dictionaries using the Dictionaries.Add method.

The given *Text* is checked using the Check method and the results are returned as a list of *IncorrectWords*.

### Calling from JavaScript

On the JavaScript side, the endpoint is called using a jQuery ajax call:

```
async function check(text, language = "en_US") {
    var serviceURL = "api/spell/check?text=" + text + "&language=" + language;
    return await callEndpoint(serviceURL);
}
```

```
async function callEndpoint(serviceURL) {
  return new Promise(resolve => {
      $.ajax({
          type: "GET",
          url: serviceURL,
          contentType: 'application/json',
          success: successFunc,
          error: errorFunc
      });

      function successFunc(data, status) {
          resolve(data);
      }

      function errorFunc(data) {
          throw "Request failed. Please try again later.";
      }
  });
  }
```

The spell checking functions are encapsulated in a private scope and exposed as properties in the *TXSpell* JavaScript object. This way, the *check* method can be called like this in the sample:

```
async function checkText() {
    // call the check method
    var results = await TXSpell.check(document.getElementById('textbox').textContent);

    // check console for details
    console.log(results);
    var consoleText = "";

    // loop through the results and return the text
    results.forEach(function (element) {
        consoleText += "<p>Misspelled: <strong>" + element.text + "</strong></p>";
    });

    document.getElementById('results').innerHTML = consoleText;
}
```

On a button click, the function *checkText* is called:

```
<input value="Check" type="button" onclick="checkText()" />
```

### Demo Screenshots

The following screenshot shows the sample after the *Check* button has been clicked:

![Spell Checking](https://s1-www.textcontrol.com/assets/dist/blog/2020/05/15/a/assets/check1.webp "Spell Checking")

Create Suggestions:

![Spell Checking](https://s1-www.textcontrol.com/assets/dist/blog/2020/05/15/a/assets/check2.webp "Spell Checking")

Create Synonyms:

![Spell Checking](https://s1-www.textcontrol.com/assets/dist/blog/2020/05/15/a/assets/check3.webp "Spell Checking")

Detect Languages:

![Spell Checking](https://s1-www.textcontrol.com/assets/dist/blog/2020/05/15/a/assets/check4.webp "Spell Checking")

Download the sample project and test this on your own.

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [TX Text Control 34.0 SP4 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/05/20/tx-text-control-34-0-sp4-is-now-available/llms.txt)
- [TXTextControl.Markdown.Core 34.1.0-beta: Work with Full Documents, Selection, and SubTextParts](https://www.textcontrol.com/blog/2026/04/14/txtextcontrol-markdown-core-34-1-0-beta-work-with-full-documents-selection-and-subtextparts/llms.txt)
- [TX Text Control 34.0 SP2 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/02/18/tx-text-control-34-0-sp2-is-now-available/llms.txt)
- [TX Text Control 34.0 SP1 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/12/03/tx-text-control-34-0-sp1-is-now-available/llms.txt)
- [Introducing TX Text Control 34.0: Your Next Leap in Document Processing](https://www.textcontrol.com/blog/2025/11/10/introducing-tx-text-control-34-0-your-next-leap-in-document-processing/llms.txt)
- [Sneak Peek: TX Text Control 34.0 Coming November 2025](https://www.textcontrol.com/blog/2025/10/02/sneak-peek-tx-text-control-34-0-coming-november-2025/llms.txt)
- [TX Text Control 33.0 SP3 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/08/14/tx-text-control-33-0-sp3-is-now-available/llms.txt)
- [TX Text Control 33.0 SP2 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/06/18/tx-text-control-33-0-sp2-is-now-available/llms.txt)
- [Document Lifecycle Optimization: Leveraging TX Text Control's Internal Format](https://www.textcontrol.com/blog/2025/05/16/document-lifecycle-optimization-leveraging-tx-text-controls-internal-format/llms.txt)
- [Expert Implementation Services for Legacy System Modernization](https://www.textcontrol.com/blog/2025/05/07/expert-implementation-services-for-legacy-system-modernization/llms.txt)
- [Service Pack Releases: What's New in TX Text Control 33.0 SP1 and 32.0 SP5](https://www.textcontrol.com/blog/2025/05/07/service-pack-releases-whats-new-in-tx-text-control-33-0-sp1-and-32-0-sp5/llms.txt)
- [Top 5 Real-World Applications for TX Text Control Document Processing Libraries](https://www.textcontrol.com/blog/2025/04/01/top-5-real-world-applications-for-tx-text-control-document-processing-libraries/llms.txt)
- [DWX Developer Week Moves to Mannheim - And Text Control Is on Board!](https://www.textcontrol.com/blog/2025/03/19/dwx-developer-week-moves-to-mannheim-and-tx-text-control-is-on-board/llms.txt)
- [The Wait is Over: TX Text Control for Linux is Officially Here](https://www.textcontrol.com/blog/2025/03/12/the-wait-is-over-tx-text-control-for-linux-is-officially-here/llms.txt)
- [Splitting Tables at Bookmark Positions and Cloning Table Headers](https://www.textcontrol.com/blog/2025/02/13/splitting-tables-at-bookmark-positions-and-cloning-table-headers/llms.txt)
- [Full .NET 9 Support in Text Control .NET Components for ASP.NET Core, Windows Forms, and WPF](https://www.textcontrol.com/blog/2024/11/11/full-net-9-support-in-text-control-net-components-for-asp-net-core-windows-forms-and-wpf/llms.txt)
- [Toggle Field Codes in TX Text Control](https://www.textcontrol.com/blog/2024/11/07/toggle-field-codes-in-tx-text-control/llms.txt)
- [Designing a MailMerge Web API Endpoint with ASP.NET Core in C#](https://www.textcontrol.com/blog/2024/07/12/designing-a-mailmerge-web-api-endpoint-with-asp-net-core-in-c-sharp/llms.txt)
- [Inserting MergeBlocks with the DataSourceManager and Applying Table Styles in C#](https://www.textcontrol.com/blog/2024/04/09/inserting-mergeblocks-with-the-datasourcemanager-and-applying-table-styles-in-csharp/llms.txt)
- [Sneak Peek 32.0: Modifying the Normal Stylesheet](https://www.textcontrol.com/blog/2023/07/04/sneak-peek-320-modifying-the-normal-stylesheet/llms.txt)
- [Merging Form Fields using the MailMerge Class](https://www.textcontrol.com/blog/2022/02/21/merging-form-fields-using-the-mailmerge-class/llms.txt)
- [MailMerge: Rendering Conditional Table Rows](https://www.textcontrol.com/blog/2022/02/17/mailmerge-rendering-conditional-table-rows/llms.txt)
- [Version 30.0: Changes in Licenses.licx](https://www.textcontrol.com/blog/2021/12/02/version-30-changes-in-licenses-licx/llms.txt)
