Products Technologies Demo Docs Blog Support Company

Creating an ASP.NET Core Web Application using TXTextControl.Web

The TX Text Control Online Document Editor TXTextControl.Web can be used in ASP.NET (.NET Framework) and ASP.NET Core Web Applications. This article shows how to create an ASP.NET Core Web Application using multi-platform NuGet package of TXTextControl.Web and Visual Studio 2019.

Creating an ASP.NET Core Web Application using TXTextControl.Web

This tutorial shows how to create a new ASP.NET Core Web Application using the TX Text Control Document Editor TXTextControl.Web using Visual Studio 2019.

For this tutorial, the setup of TX Text Control .NET Server must be installed.

Creating the Application

  1. Open Visual Studio 2019, create a new project and select ASP.NET Core Web Application as the project template.

    ASP.NET Core Web Application

    Confirm with Next.

  2. In the next dialog, specify a project name and location and confirm with Create.

  3. In the next dialog, select ASP.NET Core 2.1 or better from the available frameworks and choose Web Application (Model-View-Controller) as the project template.

    ASP.NET Core Web Application

    Finalize with Create.

Adding the NuGet Package

  1. In the Solution Explorer, select your created project and choose Manage NuGet Packages... from the Project main menu.

    Browse for txtextcontrol.web and Install the latest version of the TXTextControl.Web package.

    ASP.NET Core Web Application

Configure the Application

  1. Open the Startup.cs file located in the project's root folder. In the Configure method, add the following code to the end of the method:

    // enable local 'App_Data' folder to access local documents
    AppDomain.CurrentDomain.SetData("DataDirectory", System.IO.Path.Combine(env.ContentRootPath, "App_Data"));
    
    // serve static linked files (JavaScript and CSS for the editor)
    app.UseStaticFiles(new StaticFileOptions
    {
        FileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(
           System.IO.Path.Combine(System.IO.Path.GetDirectoryName(
               System.Reflection.Assembly.GetEntryAssembly().Location),
               "TXTextControl.Web")),
        RequestPath = "/TXTextControl.Web"
    });
    
    // enable Web Sockets
    app.UseWebSockets();
    
    // attach the Text Control WebSocketHandler middleware
    app.UseMiddleware<TXTextControl.Web.WebSocketMiddleware>();
  2. Select the project in the Solution Explorer and create a new folder named App_Data by clicking New Folder from the Project main menu.

    Select the newly created folder App_Data and click Add Existing Item... from the Project main menu.

    Browse to the following TX Text Control installation folder:

    C:\Program Files\Text Control GmbH\TX Text Control 28.0.NET Server for ASP.NET\Samples\Demo\

    Select the file invoice.docx confirm with Add.

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:

    @using TXTextControl.Web
    @using TXTextControl.Web.MVC
    
    @Html.TXTextControl().TextControl(settings =>
    {
        settings.Dock = DockStyle.Window;
    }).LoadText("App_Data/invoice.docx",StreamType.WordprocessingML).Render()

Compile and start the application.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

ASP.NET

Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.

ASP.NET Core
Angular
Blazor
JavaScript
React
  • Angular
  • Blazor
  • React
  • JavaScript
  • ASP.NET MVC, ASP.NET Core, and WebForms

Learn more Trial token Download trial

Related Posts

ASP.NETDocument EditorMail Merge

ASP.NET Core: Server-Side MailMerge

This article shows how to use a model as the data excerpt file and to merge the created template server-side.


ASP.NETDocument Editor.NET Core

TXTextControl.Web for ASP.NET Core Web Applications Released

We just released the .NET Core client-side library of the TX Text Control Online Document Editor.


ASP.NETASP.NET CoreDocument Editor

Getting Started Video Tutorial: Document Editor in ASP.NET Core C# on Linux

This video tutorial shows how to use the Document Editor in an ASP.NET Core application using C# and deploy on Linux using Docker. This tutorial is part of the TX Text Control Getting Started…


ASP.NETDocument EditorDocument Protection

Document Protection in ASP.NET with TX Text Control: Healthcare Use Cases

This article explores document protection use cases in the healthcare domain. It also explains how to assign usernames, configure edit modes, and use editable regions based on user roles using the…


ASP.NETApp ServicesASP.NET Core

Deploying the TX Text Control Document Editor in an ASP.NET Core Web App to…

This tutorial shows how to deploy the TX Text Control Document Editor to Azure App Services using an ASP.NET Core Web App. The Document Editor is a powerful word processing component that can be…