# ASP.NET Core: Deploying the TX Text Control Document Viewer to Azure App Services

> Unlike the document editor, the document viewer doesn't require a TCP synchronization service to render the document. But it also requires a backend that runs on a Windows Server instance. This article shows how to deploy the backend and how to connect the viewer to this backend.

- **Author:** Bjoern Meyer
- **Published:** 2022-11-29
- **Modified:** 2025-11-16
- **Description:** Unlike the document editor, the document viewer doesn't require a TCP synchronization service to render the document. But it also requires a backend that runs on a Windows Server instance. This article shows how to deploy the backend and how to connect the viewer to this backend.
- **4 min read** (602 words)
- **Tags:**
  - ASP.NET
  - Document Viewer
  - Linux
  - .NET Core
- **LLMs.txt URL:** https://www.textcontrol.com/blog/2022/11/29/deploying-document-viewer-to-linux/llms.txt
- **LLMs-full.txt URL:** https://www.textcontrol.com/blog/2022/11/29/deploying-document-viewer-to-linux/llms-full.txt
- **Canonical URL:** https://www.textcontrol.com/blog/2022/11/29/deploying-document-viewer-to-linux/

---

Unlike the document editor, the document viewer doesn't require a TCP synchronization service to render the document. But it also requires an ASP.NET backend application that runs on a Windows Server instance. This article shows how to deploy the backend and how to connect the viewer to this backend.

When integrating the TX Text Control ASP.NET document viewer into an ASP.NET Core Web Application, the viewer requires two parts:

- **MVC NuGet package or(!) pure JavaScript**The ASP.NET MVC NuGet package for the client-side components
- **Backend: Integrated Web API controller**Server-side backend Web API controller to manage the viewer

Both required components are part of the [DocumentViewer NuGet package](https://www.nuget.org/packages/TXTextControl.Web.DocumentViewer/). When deploying your application to App Services or Linux, the document viewer can be initialized client-side using pure JavaScript by connecting it to a separate ASP.NET backend.

The following diagram shows this deployment architecture:

![Deploy to App Services](https://s1-www.textcontrol.com/assets/dist/blog/2022/11/29/a/assets/diagram.webp "Deploy to App Services")

### Creating the ASP.NET Backend Web Application

Make sure that you downloaded the latest version of Visual Studio 2022 that comes with the [.NET 6 SDK](https://dotnet.microsoft.com/download/dotnet/6.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 6 (Long-term support)* as the *Framework* and confirm with *Create*.
    
    ![Creating the .NET 6 project](https://s1-www.textcontrol.com/assets/dist/blog/2022/11/29/a/assets/visualstudio1.webp "Creating the .NET 6 project")

### Adding the NuGet Packages

5. 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.Web.DocumentViewer*
    - *TXTextControl.TextControl.ASP.SDK*
    
    ![ASP.NET Core Web Application](https://s1-www.textcontrol.com/assets/dist/blog/2022/11/29/a/assets/visualstudio2.webp "ASP.NET Core Web Application")

### Adding CORS

1. Find the *Program.cs* file in the *Solution Explorer* and add the following service to the *builder.Services* section before calling *builder.Build();*:
    
    ```
    builder.Services.AddCors(opt =>
    {
    	opt.AddPolicy(name: "CorsPolicy", builder =>
    	{
    		builder.AllowAnyOrigin()
    			.AllowAnyHeader()
    			.AllowAnyMethod();
    	});
    });
    ```
2. Add this policy to the *app* method before the *app.UseRouting();* entry:
    
    ```
    app.UseCors("CorsPolicy");
    ```
    
    > **Why CORS?**
    > 
    > Enabling CORS is required as we are accessing the backend controller from another application.

### Adding the Document Viewer to your ASP.NET Core Web Application

Open your existing ASP.NET Core Web Application or create a new application where you would like to add the document viewer to.

1. Add the following *script* tag to one of your view files:
    
    ```
    <script src="https://localhost:44353/TextControl/GetResource?Resource=minimized.tx-viewer.min.js"></script>
    ```
    
    Replace *44353* with the port number of your created backend ASP.NET Core application you created in step 1.
    
    > **Pro Tip**
    > 
    > When deploying your backend to a production server, replace the complete location *https://localhost:44353* with your actual URL.
2. Add a hosting element to your HTML:
    
    ```
    <div id="txViewerHost"></div>
    ```
3. Add the following *script* tag to your HTML and set the *id* of the hosting element to the *containerID* property:
    
    ```
    <script>
    // create a new DocumentViewer
    TXDocumentViewer.init( {
    containerID: 'txViewerHost',
    viewerSettings: {
    toolbarDocked: true,
    dock: "Fill",
    isSelectionActivated: true,
    showThumbnailPane: true,
    basePath: 'https://localhost:44353',
    }
    });
    </script>
    ```
    
    Also here, replace the *basePath* with your endpoint URL.

> **Deploying**
> 
> The backend application created in step 1 must be deployed to a full Windows VM (or Azure App Services in *container mode*). Your application in step 2 can be deployed to any platform including Azure App Services or it can be deployed to Linux.

---

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

- [ASP.NET Core: Deploying the TX Text Control Document Viewer to Azure App Services](https://www.textcontrol.com/blog/2021/11/08/deploying-document-viewer-to-linux/llms.txt)
- [ASP.NET Core: Deploying the TX Text Control 32.0 SP2 Document Editor to Linux](https://www.textcontrol.com/blog/2024/01/22/deploying-tx-text-control-to-linux/llms.txt)
- [ASP.NET Core: Deploying the TX Text Control Document Editor to Linux](https://www.textcontrol.com/blog/2021/10/29/deploying-tx-text-control-to-linux/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)
- [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)
- [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)
- [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 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 Viewer for Blazor in ASP.NET Core](https://www.textcontrol.com/blog/2025/03/25/getting-started-document-viewer-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)
- [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)
- [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)
- [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: ServerTextControl and MailMerge in a .NET 8 Console Application on Linux with Docker and WSL](https://www.textcontrol.com/blog/2025/03/12/getting-started-servertextcontrol-and-mailmerge-in-a-net-8-console-application-on-linux-with-docker-and-wsl/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)
- [Version 33.0 Preview: NuGet Packages Explained and Why we Minimize Dependencies](https://www.textcontrol.com/blog/2025/02/24/version-33-0-preview-nuget-packages-explained-and-why-we-minimize-dependencies/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)
- [TX Text Control Linux Preview: Font Handling](https://www.textcontrol.com/blog/2024/12/28/tx-text-control-linux-preview-font-handling/llms.txt)
- [Celebrating a Successful 2024: Key Achievements and Exciting Outlook for 2025](https://www.textcontrol.com/blog/2024/12/17/celebrating-a-successful-2024-key-achievements-and-exciting-outlook-for-2025/llms.txt)
