TX Text Control .NET Server for ASP.NET can be used to create powerful document processing Web APIs in ASP.NET Core Web Applications. This tutorial shows how to deploy these applications to Docker.

Creating the Application

Create a new ASP.NET Core Web Application by following this tutorial in our documentation:

ASP.NET Core Web Applications

After following these tutorial steps, you will have an MVC project framework that can utilize TX Text Control to create documents.

Adding a Web API

In the next step, a simple Web API endpoint is created that converts HTML input to PDF and returns a PDF document.

  1. In the Solution Explorer, right-click Controllers and choose Add -> Controller from the context menu. In the opened dialog, select API Controller - Empty and confirm with Add.

    Creating the Web API

  2. Name the controller DocumentController and confirm with Add.

  3. Add the following code to the newly created controller:

  4. Start the application and navigate to the endpoint directly to test the functionality. Navigate to (replace the port number with the port number of your application):


    It should return a long base64 encoded string which is essentially a PDF with the word Test. If you see a long base64 encoded string, the Web API works.

Creating the Dockerfile

A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.

A Docker image is created automatically based on a Dockerfile by reading the instructions. The following steps are required to prepare a build process:

  1. Create a new folder named docker-test that contains the following sub-folders and files:

    • Folder named app
    • A text file named Dockerfile (no extension)
  2. In Visual Studio with the application opened that should be deployed, right-click the project in the Solution Explorer and choose Publish.

    In the opened page Publish, click the Start button to open the Pick a publish target dialog. Select Folder as the target:

    Creating the Web API

  3. Click the Advanced... link to open the AdvancedSettings dialog. Make sure to select Framework-Dependent as the Deployment Mode and win-x64 as the Target Runtime:

    Creating the Web API

    Confirm with Save. Close the Pick a publish target dialog by clicking the Create Profile button.

  4. Click Publish to publish your application. Note the location of the publish folder or click the Creating the Web API icon to copy the path to the clipboard.

    Creating the Web API

  5. Copy the content of the publish folder to the newly created app folder from step 1.

  6. Open the Dockerfile in a text editor such as Visual Studio Code. The Dockerfile script creates a Windows Server container with all requirements including .NET Core run-times and Visual C++ Redistributables.

    There are two ways to deploy the application in Docker:

    • Using IIS
    • Without IIS

    Continue this tutorial with the desired approach.

    Using IIS

    Copy the following code to your Dockerfile:


    Without IIS

    Copy the following code to your Dockerfile:


Creating the Docker Image

In order to create the image, use the following commands:

  1. Assume that you have installed Docker for Windows, open a PowerShell command window with explicit administrator rights and change to the directory where you created the folder docker-test.

    Creating the Web API

  2. Type in the following command to build the Docker image based on the Dockerfile in the same directory:

    docker build -t txcore .

    Creating the Web API

Running the Docker Container

  1. Depending on the Dockerfile you used in step 6, start the container with one of the following commands:

    Using IIS

    docker run -it --rm -p 5000:80 --name aspnetcore_sample txcore

    Without IIS

    docker run -it --rm -p 5000:80 -e ASPNETCORE_URLS=http://+:80 --name aspnetcore_sample txcore

In the Docker Dashboard, you can see the running container listening on port 5000:

Creating the Web API

Open a browser and navigate to http://localhost:5000 to see your deployed web application.