# Building an ASP.NET Core Backend Application to Host the Document Editor and Document Viewer

> This article explains how to create an ASP.NET Core backend application to host the Document Editor and Document Viewer. This backend application is required to provide the required functionality to the frontend applications built with Angular, React, or JavaScript.

- **Author:** Bjoern Meyer
- **Published:** 2024-03-14
- **Modified:** 2025-11-16
- **Description:** This article explains how to create an ASP.NET Core backend application to host the Document Editor and Document Viewer. This backend application is required to provide the required functionality to the frontend applications built with Angular, React, or JavaScript.
- **3 min read** (493 words)
- **Tags:**
  - ASP.NET
  - ASP.NET Core
  - Angular
  - React
  - JavaScript
  - Document Editor
  - Document Viewer
  - Backend
- **LLMs.txt URL:** https://www.textcontrol.com/blog/2024/03/14/building-an-asp-net-core-backend-application-to-host-the-document-editor-and-document-viewer/llms.txt
- **LLMs-full.txt URL:** https://www.textcontrol.com/blog/2024/03/14/building-an-asp-net-core-backend-application-to-host-the-document-editor-and-document-viewer/llms-full.txt
- **Canonical URL:** https://www.textcontrol.com/blog/2024/03/14/building-an-asp-net-core-backend-application-to-host-the-document-editor-and-document-viewer/

---

All [client-side packages](https://www.textcontrol.com/product/client-package/), including those for Angular, React, and JavaScript, require an ASP.NET Core backend application based on TX Text Control .NET Server to host the Document Editor and Document Viewer.

> **Prerequisites**
> 
> In order to create a back-end application, you must have the TX Text Control .NET Server installed on your machine. You can download a trial version here.
> 
> [Download Trial Version ](https://www.textcontrol.com/product/tx-text-control-dotnet-server/download/)

### Creating the Application

1. Open Visual Studio and create a new *ASP.NET Core Empty* application.
    
    ![Creating the application](https://s1-www.textcontrol.com/assets/dist/blog/2024/03/14/b/assets/visualstudio1.webp "Creating the application")
2. Select a project name, location and solution name in the next dialog and confirm with *Next*.
3. In the next dialog, choose *.NET 8 (Long Term Support)* as the *Framework* and confirm with *Create*.

### 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* from the *Package* source drop-down.
    
    Install the latest versions of the following packages:
    
    
    - **TXTextControl.TextControl.ASP.SDK**
    - **TXTextControl.Web**
    - **TXTextControl.Web.DocumentViewer**
    
    ![Adding the NuGet packages](https://s1-www.textcontrol.com/assets/dist/blog/2024/03/14/b/assets/visualstudio2.webp "Adding the NuGet packages")
2. Select *nuget.org* as the *Package* source and check for updates of the above packages. Update them if a newer package is available.

### Adding the Middleware

1. Open the *Program.cs* file located in the project's root folder. Replace the complete code with the following code:
    
    ```
    using TXTextControl.Web;
    using TXTextControl.Web.MVC.DocumentViewer;
    
    var builder = WebApplication.CreateBuilder(args);
    
    // adding CORS policy to allow all origins
    builder.Services.AddCors(options =>
    {
    options.AddDefaultPolicy(
    builder =>
    {
    builder.AllowAnyOrigin()
    .AllowAnyMethod()
    .AllowAnyHeader();
    });
    });
    
    // adding controllers for DocumentViewer Web API
    builder.Services.AddControllers();
    
    var app = builder.Build();
    
    app.MapGet("/", () => "TX Text Control .NET Server for ASP.NET Backend is up and running!");
    
    app.UseRouting();
    
    // adding CORS middleware
    app.UseCors();
    
    // adding WebSockets middleware
    app.UseWebSockets();
    
    // adding TX Text Control middleware
    app.UseTXWebSocketMiddleware();
    app.UseTXDocumentViewer();
    
    app.Run();
    ```

### Running the Backend

1. Press *F5* to start the application.

After launching the application, you should see the following screen.

![Running the backend](https://s1-www.textcontrol.com/assets/dist/blog/2024/03/14/b/assets/visualstudio3.webp "Running the backend")

### Connecting Client-Site Packages

The Document Editor and Document Viewer instances used in your Angular, React, or JavaScript applications can now be connected to your newly created backend.

#### Document Editor

In your Angular, React, or JavaScript project, change the *webSocketURL* attribute of the Document Editor component in the to the URL of your backend application created above. For example in Angular:

```
<tx-document-editor
width="1000px"
height="500px"
webSocketURL="wss://localhost:7118/api/TXWebSocket">
</tx-document-editor>
```

Make sure that *wss* is used if the backend is hosted using https and that *ws* is used in the case of http.

#### Document Viewer

In your Angular, React, or JavaScript project, change the *basePath* attribute of the Document Viewer component in the to the URL of your backend application created above. For example in Angular:

```
<tx-document-viewer
width="1000px"
height="800px"
basePath="https://localhost:7118"
</tx-document-viewer>
```

---

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

- [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)
- [Observe When the Reporting Preview Tab is Active Using MutationObserver](https://www.textcontrol.com/blog/2024/07/23/observe-when-the-reporting-preview-tab-is-active-using-mutationobserver/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)
- [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)
- [Announcing Our Work on a Blazor Component for Document Editing and Viewing](https://www.textcontrol.com/blog/2025/01/24/announcing-our-work-on-a-blazor-component-for-document-editing-and-viewing/llms.txt)
- [Preparing Documents for E-Signing for Multiple Signers in .NET C#](https://www.textcontrol.com/blog/2024/11/13/preparing-documents-for-e-signing-for-multiple-signers-in-net-c-sharp/llms.txt)
- [ASP.NET Core: Use the Document Editor and Viewer in the Same Razor View](https://www.textcontrol.com/blog/2024/11/08/asp-net-core-use-the-document-editor-and-viewer-in-the-same-razor-view/llms.txt)
- [Adding a Security Middleware to ASP.NET Core Web Applications to Protect TX Text Control Document Editor and Document Viewer Endpoints](https://www.textcontrol.com/blog/2024/03/18/adding-a-security-middleware-to-asp-net-core-web-applications-to-protect-tx-text-control-document-editor-and-document-viewer-endpoints/llms.txt)
- [TX Text Control React Packages Released](https://www.textcontrol.com/blog/2024/02/29/tx-text-control-react-packages-released/llms.txt)
- [Creating an Angular Application with an ASP.NET Core Backend](https://www.textcontrol.com/blog/2023/05/05/creating-an-angular-application-with-an-aspnet-core-backend/llms.txt)
- [JavaScript: Avoid Flickering and Visual Updates by Grouping Undo Steps](https://www.textcontrol.com/blog/2022/07/25/javascript-avoid-flickering-and-visual-updates-by-grouping-undo-steps/llms.txt)
- [Load Balancing: Using Different TCP Service Locations using a Custom WebSocketHandler](https://www.textcontrol.com/blog/2021/11/02/using-different-tcp-service-locations/llms.txt)
- [JavaScript Functions for Typical Form Field Tasks](https://www.textcontrol.com/blog/2020/04/15/javascript-functions-for-typical-form-field-tasks/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)
- [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)
- [5 Document Workflows You Can Automate With JavaScript Rich Text Editor](https://www.textcontrol.com/blog/2026/01/14/five-document-workflows-you-can-automate-with-javascript-rich-text-editor/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)
- [High-Performance Text Replacement in Large DOCX Files using C# .NET](https://www.textcontrol.com/blog/2025/07/30/high-performance-text-replacement-in-large-docx-files-using-csharp-dotnet/llms.txt)
- [Document Viewer 33.2.1 Released: New Event and Bug Fixes](https://www.textcontrol.com/blog/2025/07/30/document-viewer-33-2-1-released-new-event-and-bug-fixes/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)
- [Add JavaScript to PDFs with TX Text Control in C# .NET: Time-Based Alerts Made Easy](https://www.textcontrol.com/blog/2025/06/13/add-javascript-to-pdfs-with-tx-text-control-in-c-dot-net-time-based-alerts-made-easy/llms.txt)
- [Deploying the TX Text Control Document Editor Backend Web Server in Docker](https://www.textcontrol.com/blog/2025/04/10/deploying-the-tx-text-control-document-editor-backend-web-server-in-docker/llms.txt)
- [Configuring the TX Text Control Document Editor Backend Web Server, including Port and Logging](https://www.textcontrol.com/blog/2025/03/28/configuring-the-tx-text-control-document-editor-backend-web-server-including-port-and-logging/llms.txt)
