Creating an ASP.NET MVC Application With Razor
This tutorial shows how to integrate TextControl.Web into an MVC application with Razor.

Create Your Application
-
Make sure that you installed at least a trial version of TX Text Control .NET Server on your development machine:
-
Open Visual Studio and create a new ASP.NET Web Application. Make sure to select at least .NET Framework 4.5 as the .NET Framework project version.
-
In the next dialog New ASP.NET Project, select Empty as your project template. Check the checkboxes MVC and Web API to add the folders and core references. Close the dialog with OK.
-
Click Manage NuGet Packages... from the Project main menu. Select nuget.org from the Online package source panel. In the upper right corner, search for TXTextControl.Web. Find the latest version and click on Install.
Make sure to update the Microsoft ASP.NET MVC packages, if they are available in the Updates panel. Close the dialog with Close.
-
In the Solution Explorer, select App_Data and choose New Folder from the Project main menu and name the folder Documents. Select the newly created folder Documents 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 two files invoice.docx and sample_db.xml and confirm with Add.
-
In the Solution Explorer, select the Controllers folder and choose Add New Item... from the Project main menu. In the opened dialog Add New Item, select MVC 5 Controller - Empty and confirm with Add. Set the name to HomeController and insert it by clicking the Add button.
-
In the Solution Explorer, select the newly created folder Home and choose Add New Item... from the Project main menu. Select MVC 5 View Page (Razor), name it Index and confirm with Add.
-
Open the Index.cshtml view from the Views -> Home folder. Add the following Razor code to the top of the view:
@using TXTextControl.Web @using TXTextControl.Web.MVC
-
Add the following HtmlHelper code to the end of the view page:
@Html.TXTextControl().TextControl(settings => { settings.DocumentFileDirectory = Server.MapPath("~/App_Data/Documents"); }).LoadXMLDatabase( Server.MapPath("~/App_Data/Documents/sample_db.xml")).LoadText( Server.MapPath("~/App_Data/Documents/invoice.docx"), StreamType.WordprocessingML).Render()
The complete Index.cshtml should now look like this:
@using TXTextControl.Web @using TXTextControl.Web.MVC @{ ViewBag.Title = "Index"; } <h2>Index</h2> @Html.TXTextControl().TextControl(settings => { settings.DocumentFileDirectory = Server.MapPath("~/App_Data/Documents"); }).LoadXMLDatabase( Server.MapPath("~/App_Data/Documents/sample_db.xml")).LoadText( Server.MapPath("~/App_Data/Documents/invoice.docx"), StreamType.WordprocessingML).Render()
-
Compile and start the application.
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.
- Angular
- Blazor
- React
- JavaScript
- ASP.NET MVC, ASP.NET Core, and WebForms
Related Posts
Creating an ASP.NET MVC DocumentViewer Application With Razor
Create a simple ASP.NET (MVC) application that uses the HTML5 document viewer.
Creating Your First ASP.NET Reporting Application
This tutorial shows how to use the MailMerge component in an ASP.NET Web application to merge a template with data to create an Adobe PDF document.
Creating an ASP.NET Web Forms AJAX Application
This tutorial shows how to use the HTML5 based TextControl to create a Web based word processor and template designer. Using the built-in File menu, you can load and save documents from and to a…
TextControl.Web: Creating an MVC Application with Razor
This tutorial shows how to integrate TextControl.Web into an MVC application with Razor. Because of the architecture and complexity of the design, the ASP.NET component TextControl.Web is a Web…
ASP.NETASP.NET CoreDocument Editor
ASP.NET Core: Use the Document Editor and Viewer in the Same Razor View
The Document Editor and Viewer typically have separate roles in web apps, with the editor used for creating and editing documents, often occupying the full view. Some applications, however,…