Prerequisites

You need to download and install the trial version of TX Text Control .NET Server for ASP.NET to host the Document Editor backend:

Introduction

This tutorial shows how to create a simple ASP.NET Core web application that hosts the TX Text Control .NET Server for ASP.NET backend. The backend is used to render and edit documents in the browser using the TX Text Control Document Editor.

Container and Linux Distributions

TX Text Control supports most popular Linux distributions and can be run in VMs, Docker containers, or any hyperscaler environment such as Azure App Services, AWS Elastic Beanstalk, or Google Cloud Run. This tutorial shows how to create an ASP.NET Core Web application that hosts the TX Text Control in a standard Linux container using the default Visual Studio template.

Creating the Application

Make sure that you downloaded the latest version of Visual Studio 2022 that comes with the .NET 8 SDK.

  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. Enter a project name and choose a location to save the project. Confirm with Next.

  4. Choose .NET 8.0 (Long Term Support) as the Framework.

  5. Enable the Enable container support checkbox and choose Linux as the Container OS.

  6. Choose Dockerfile for the Container build type option and confirm with Create.

    Creating the .NET 8 project

Adding the Web Server Backend

  1. 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:

    Loading...
  2. 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 for ASP.NET:

    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.

  3. Select the added files in the Solution Explorer and set the Copy to Output Directory property to Copy always.

Adding the NuGet Packages

  1. 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

Configure the Application

  1. Open the Program.cs file located in the project's root folder.

    After builder.Services.AddControllersWithViews();, add the following code:

    Loading...

    At the very top of the file, insert the following code:

    Loading...

    Add the following code after the entry app.UseStaticFiles();:

    Loading...

    The overall Program.cs file should look like this:

    Loading...

Adding the Control to the View

  1. 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:

    Loading...

Starting the Application

We will use the Dockerfile as is and use the default Visual Studio template using a Linux container from the official Docker Hub repository.

  1. Start the application by pressing F5 or by choosing Debug -> Start Debugging from the main menu.