# Getting Started: Document Editor with ASP.NET Core and Linux WSL Support

> In this article, we will create a simple document editor application using the Document Editor component from the TX Text Control .NET Server product. We will use ASP.NET Core and run the application on Linux using Windows Subsystem for Linux (WSL).

- **Author:** Bjoern Meyer
- **Published:** 2025-03-12
- **Modified:** 2025-11-16
- **Description:** In this article, we will create a simple document editor application using the Document Editor component from the TX Text Control .NET Server product. We will use ASP.NET Core and run the application on Linux using Windows Subsystem for Linux (WSL).
- **5 min read** (849 words)
- **Tags:**
  - ASP.NET Core
  - Document Editor
  - Linux
  - WSL
- **Web URL:** https://www.textcontrol.com/blog/2025/03/12/getting-started-document-editor-with-asp-net-core-and-linux-wsl-support/
- **LLMs URL:** https://www.textcontrol.com/blog/2025/03/12/getting-started-document-editor-with-asp-net-core-and-linux-wsl-support/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2025/03/12/getting-started-document-editor-with-asp-net-core-and-linux-wsl-support/llms-full.txt

---

> ### Prerequisites
> 
> You need to download and install the trial version of TX Text Control .NET Server to host the Document Editor backend:
> 
> - [Download Trial Version](https://www.textcontrol.com/product/tx-text-control-dotnet-server/download/)  
>     Setup download and installation required.

### Creating the Application

Make sure that you downloaded the latest version of Visual Studio 2022 that comes with the [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0).

1. In Visual Studio 2022, create a new project by choosing *Create a new project*.
2. Select *ASP.NET Core Web App (Model-View-Controller)* as the project template and confirm with *Next*.
3. Choose a name for your project and confirm with *Next*.
4. In the next dialog, choose *.NET 8 (Long Term Support)* as the *Framework* and confirm with *Create*.
    
    ![Creating the .NET 8 project](https://s1-www.textcontrol.com/assets/dist/blog/2025/03/12/a/assets/visualstudio1.webp "Creating the .NET 8 project")

#### Adding the Web Server Backend

5. Create a new class by right-clicking the project in the *Solution Explorer* and choose *Add -> Class...*. Name the class *TXWebServerProcess.cs* and confirm with *Add*. Replace the complete content with the following code:
    
    ```
    using System.Diagnostics;
    using System.Reflection;
    
    public class TXWebServerProcess : IHostedService
    {
        private readonly ILogger<TXWebServerProcess> _logger;
    
        public TXWebServerProcess(ILogger<TXWebServerProcess> logger) => _logger = logger;
    
        public Task StartAsync(CancellationToken cancellationToken)
        {
            try
            {
                string? path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                string dllPath = Path.Combine(path ?? "", "TXTextControl.Web.Server.Core.dll");
    
                if (string.IsNullOrEmpty(path) || !File.Exists(dllPath))
                    _logger.LogWarning("TX Web Server process could not be started.");
                else
                {
                    Process.Start(new ProcessStartInfo("dotnet", $"\"{dllPath}\" &") { UseShellExecute = true, WorkingDirectory = path });
                    _logger.LogInformation("TX Web Server process started.");
                }
            }
            catch (Exception ex) { _logger.LogError(ex, "Error starting TX Web Server."); }
    
            return Task.CompletedTask;
        }
    
        public Task StopAsync(CancellationToken cancellationToken)
        {
            _logger.LogInformation("Stopping TX Web Server process...");
            return Task.CompletedTask;
        }
    }
    ```
6. Now right-click the project in the *Solution Explorer* and choose *Add -> Existing Item...*. Navigate to the installation folder of TX Text Control .NET Server:
    
    *C:\\Program Files\\Text Control GmbH\\TX Text Control 33.0.NET Server for ASP.NET\\Assembly\\net8.0*
    
    Set the file filter to *All Files (\*.\*)* and select the following files:
    
    
    - *TXTextControl.Web.Server.Core.deps.json*
    - *TXTextControl.Web.Server.Core.dll*
    - *TXTextControl.Web.Server.Core.Process.deps.json*
    - *TXTextControl.Web.Server.Core.Process.dll*
    - *TXTextControl.Web.Server.Core.Process.runtimeconfig.json*
    - *TXTextControl.Web.Server.Core.runtimeconfig.json*
    - *TXTextControl.Web.Server.Core.config.json*
    
    Confirm with *Add*.
7. Select the added files in the *Solution Explorer* and set the *Copy to Output Directory* property to *Copy always*.

#### Adding the NuGet Packages

8. In the *Solution Explorer*, select your created project and choose *Manage NuGet Packages...* from the *Project* main menu. Select **Text Control Offline Packages** as the *Package source*.
    
    Install the following packages:
    
    
    - **TXTextControl.Web**
    - **TXTextControl.TextControl.Core.SDK**
    
    ![ASP.NET Core Web Application](https://s1-www.textcontrol.com/assets/dist/blog/2025/03/12/a/assets/visualstudio2.webp "ASP.NET Core Web Application")

#### Configure the Application

9. Open the *Program.cs* file located in the project's root folder.
    
    After *builder.Services.AddControllersWithViews();*, add the following code:
    
    ```
    builder.Services.AddHostedService<TXWebServerProcess>();
    ```
    
    At the very top of the file, insert the following code:
    
    ```
    using TXTextControl.Web;
    ```
    
    Add the following code after the entry `app.UseStaticFiles();`:
    
    ```
    // enable Web Sockets
    app.UseWebSockets();
    
    // attach the Text Control WebSocketHandler middleware
    app.UseTXWebSocketMiddleware();
    ```
10. The overall *Program.cs* file should look like this:
    
    ```
    using TXTextControl.Web;
    
    var builder = WebApplication.CreateBuilder(args);
    
    // Add services to the container.
    builder.Services.AddControllersWithViews();
    builder.Services.AddHostedService<TXWebServerProcess>();
    
    var app = builder.Build();
    
    
    // Configure the HTTP request pipeline.
    if (!app.Environment.IsDevelopment())
    {
        app.UseExceptionHandler("/Home/Error");
        // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
        app.UseHsts();
    }
    
    app.UseHttpsRedirection();
    app.UseStaticFiles();
    
    // enable Web Sockets
    app.UseWebSockets();
    
    // attach the Text Control WebSocketHandler middleware
    app.UseTXWebSocketMiddleware();
    
    app.UseRouting();
    
    app.UseAuthorization();
    
    app.MapControllerRoute(
        name: "default",
        pattern: "{controller=Home}/{action=Index}/{id?}");
    
    app.Run();
    ```

#### Adding the Control to the View

10. Find the *Index.cshtml* file in the *Views -> Home* folder. Replace the complete content with the following code to add the document editor to the view:
    
    ```
    @using TXTextControl.Web.MVC
        
    @{
        var sDocument = "<html><body><p>Welcome to <strong>Text Control</strong></p></body></html>";
    }
    
    @Html.TXTextControl().TextControl(settings => {
        settings.UserNames = new string[] { "Tim Typer" };
    }).LoadText(sDocument, TXTextControl.Web.StringStreamType.HTMLFormat).Render()
    
    <input type="button" onclick="insertTable()" value="Insert Table" />
    
    <script>
        function insertTable() {
            TXTextControl.tables.add(5, 5, 10, function(e) {
              if (e === true) { // if added
                TXTextControl.tables.getItem(function(table) {
                  table.cells.forEach(function(cell) {
    
                    cell.setText("Cell text");
    
                  });
                }, null, 10);
              }
            })
        }
    </script>
    ```

#### Starting the Application

11. Select *WSL* as the startup profile and start the application.
    
    ![Starting the application](https://s1-www.textcontrol.com/assets/dist/blog/2025/03/12/a/assets/wsl.webp "Starting the application")

#### Enable WSL (Windows Subsystem for Linux)

In case you haven't enabled WSL yet, follow these steps:

> **Enable WSL (Windows Subsystem for Linux)**
> 
> 1. Open PowerShell as an administrator.
> 2. Run the following command:
>     
>     ```
>     wsl --install
>     ```
>     
>     This installs the default Linux distribution (usually Ubuntu) and enables necessary features.
> 3. After the installation, restart your computer.
> 
> **Set WSL 2 as the Default Version**
> 
> To set WSL 2 as the default version, follow these steps:
> 
> 1. Open PowerShell as an administrator.
> 2. Run the following command:
>     
>     ```
>     wsl --set-default-version 2
>     ```
> 3. If you haven’t installed a Linux distribution yet, you can do so via:
>     
>     ```
>     wsl --install -d Ubuntu
>     ```

---

## 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

- [Introducing TXTextControl.Web.Server.Core: A Cross-Platform Backend for TX Text Control Document Editor](https://www.textcontrol.com/blog/2025/03/13/introducing-txtextcontrol-web-server-core-a-cross-platform-backend-for-tx-text-control-document-editor/llms.txt)
- [Getting Started: Document Viewer with ASP.NET Core and Linux WSL Support](https://www.textcontrol.com/blog/2025/03/12/getting-started-document-viewer-with-asp-net-core-and-linux-wsl-support/llms.txt)
- [Getting Started: Document Editor with ASP.NET Core and Docker Support with Linux Containers](https://www.textcontrol.com/blog/2025/03/12/getting-started-document-editor-with-asp-net-core-and-docker-support-with-linux-containers/llms.txt)
- [5 Layout Patterns for Integrating the TX Text Control Document Editor in ASP.NET Core C#](https://www.textcontrol.com/blog/2026/04/09/5-layout-patterns-for-integrating-the-tx-text-control-document-editor-in-aspnet-core-csharp/llms.txt)
- [Introducing Text Control Agent Skills](https://www.textcontrol.com/blog/2026/03/27/introducing-text-control-agent-skills/llms.txt)
- [Deploying the TX Text Control Document Editor from the Private NuGet Feed to Azure App Services (Linux and Windows)](https://www.textcontrol.com/blog/2026/03/25/deploying-the-tx-text-control-document-editor-from-the-private-nuget-feed-to-azure-app-services-linux-and-windows/llms.txt)
- [Build a Custom Backstage View in ASP.NET Core with TX Text Control](https://www.textcontrol.com/blog/2026/02/17/build-a-custom-backstage-view-in-aspnet-core-with-tx-text-control/llms.txt)
- [ASP.NET Core Document Editor with Backend via the Text Control Private NuGet Feed](https://www.textcontrol.com/blog/2026/02/09/aspnet-core-document-editor-private-nuget-feed/llms.txt)
- [Document Editor with TX Spell .NET on Linux using ASP.NET Core](https://www.textcontrol.com/blog/2026/01/28/document-editor-tx-spell-net-linux-aspnet-core/llms.txt)
- [Why Document Processing Libraries Require a Document Editor](https://www.textcontrol.com/blog/2025/12/04/why-document-processing-libraries-require-a-document-editor/llms.txt)
- [Format Painter in ASP.NET Core: Building Custom Text Formatting with TX Text Control](https://www.textcontrol.com/blog/2025/09/09/format-painter-in-asp-dotnet-core-building-custom-text-formatting-with-tx-text-control/llms.txt)
- [Getting Started Video Tutorial: Document Editor in ASP.NET Core C# on Linux](https://www.textcontrol.com/blog/2025/07/29/getting-started-video-tutorial-document-editor-aspnet-core-csharp-linux/llms.txt)
- [Convert MS Word DOCX to PDF including Text Reflow using .NET C# on Linux](https://www.textcontrol.com/blog/2025/06/10/convert-ms-word-docx-to-pdf-including-text-reflow-using-dotnet-csharp-on-linux/llms.txt)
- [Announcing the Official DS Server Docker Image on Docker Hub](https://www.textcontrol.com/blog/2025/05/02/announcing-the-official-ds-server-docker-image-on-docker-hub/llms.txt)
- [Introducing DS Server 4.0: Linux-Ready and Container-Friendly](https://www.textcontrol.com/blog/2025/04/30/introducing-ds-server-4-linux-ready-and-container-friendly/llms.txt)
- [Creating a .NET Console Application with Visual Studio Code and TX Text Control (on Linux)](https://www.textcontrol.com/blog/2025/04/03/creating-a-dotnet-console-application-with-visual-studio-code-and-tx-text-control-on-linux/llms.txt)
- [TX Text Control Core vs. Classic Performance Comparison Plain Text to DOCX and PDF](https://www.textcontrol.com/blog/2025/03/31/2025-03-31-tx-text-control-core-vs-classic-performance-comparison-plain-text-to-docx-and-pdf/llms.txt)
- [Deploying the TX Text Control Document Editor in an ASP.NET Core Web App to Azure App Services](https://www.textcontrol.com/blog/2025/03/26/deploying-the-tx-text-control-document-editor-in-an-asp-net-core-web-app-to-azure-app-services/llms.txt)
- [Building an ASP.NET Core Backend (Linux and Windows) for the Document Editor and Viewer](https://www.textcontrol.com/blog/2025/03/26/building-an-asp-net-core-backend-for-the-document-editor-and-viewer/llms.txt)
- [TX Text Control for Blazor: Mail Merge Integration Tutorial](https://www.textcontrol.com/blog/2025/03/25/tx-text-control-for-blazor-mail-merge-integration-tutorial/llms.txt)
- [TX Text Control Document Editor and Viewer for Blazor Released](https://www.textcontrol.com/blog/2025/03/25/tx-text-control-document-editor-and-viewer-for-blazor-released/llms.txt)
- [Getting Started: Document Editor for Blazor in ASP.NET Core](https://www.textcontrol.com/blog/2025/03/25/getting-started-document-editor-for-blazor-in-asp-net-core/llms.txt)
- [How to Create PDF Documents with TX Text Control using C# .NET on Linux](https://www.textcontrol.com/blog/2025/03/18/how-to-create-pdf-documents-with-tx-text-control-using-c-sharp-net-on-linux/llms.txt)
- [Benchmarking TX Text Control: Classic vs. Core on Windows and Linux](https://www.textcontrol.com/blog/2025/03/14/benchmarking-tx-text-control-classic-vs-core-on-windows-and-linux/llms.txt)
- [Using TX Text Control with Ultra-Minimal Chiseled Linux Containers](https://www.textcontrol.com/blog/2025/03/12/using-tx-text-control-with-ultra-minimal-chiseled-linux-containers/llms.txt)
