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:
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
The following diagram shows this deployment architecture:
Creating the ASP.NET Backend Web Application
In Visual Studio 2019 (>= 16.5.4) or 2022, create a new project and select ASP.NET Core Web Application as the project template.
Select a project name, location and solution name in the next dialog and confirm with Create.
In the last dialog, select .NET 5 as the Target Framework and confirm with Create.
Open the Package Manager Console by choosing Package Manager Console from the Tools -> NuGet Package Manager main menu and type in the following command to install the TXTextControl.Web.DocumentViewer package:
PM> Install-Package TXTextControl.Web.DocumentViewer
While the project is selected in the Solution Explorer, choose Project -> Add Reference... to open the Reference Manager. In the opened dialog, select Browse... to select the required TX Text Control assemblies. Navigate to the installation folder of TX Text Control and select the following assemblies from the Assembly folder:
Repeat this step with the following assemblies from the Assembly/bin64 folder:
After selecting these assemblies, close the Reference Manager by confirming with OK.
While the project is selected in the Solution Explorer, choose Project -> Add Existing Item.... Browse to the TX Text Control installation folder and select the following files from the Assembly/bin64:
Select the files from step 6 in the Solution Explorer and set the Copy to Output Directory to Copy always.
While the project is selected in the Solution Explorer, choose Project -> Add New Item.... Select Text File, name the file licenses.licx and close the dialog by clicking Add.
Open the newly added file and add the following content:
Set the Build Action property to Embedded Resource.
Find the Startup.cs file in the Solution Explorer and add the following code to the ConfigureServices method:
Add this policy to the Configure method after the app.UseRouting(); entry:
Enabling CORS is required as we are accessing the backend controller from another application.
Compile and start your 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.
Add the following script tag to one of your view files:
Replace 44353 with the port number of your created backend ASP.NET Core application you created in step 1.
When deploying your backend to a production server, replace the complete location https://localhost:44353 with your actual URL.
Add a hosting element to your HTML:
Add the following script tag to your HTML and set the id of the hosting element to the containerID property:
Also here, replace the basePath with your endpoint URL.
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.