ASP.NET MVC Tutorial

Back to tutorial overview

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

  1. Make sure that you installed at least a trial version of TX Text Control .NET Server for ASP.NET on your development machine:

    Download TX Text Control .NET Server for ASP.NET trial version

  2. Open Visual Studio and create a new ASP.NET Web Application. Make sure to select .NET Framework 4.5 as the .NET Framework project version.

  3. 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.

  4. 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.

  5. 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 24.0.NET Server for ASP.NET\Samples\Demo\

    Select the two files invoice.docx and sample_db.xml and confirm with Add.

  6. 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.

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

  8. Open the Index.cshtml view from the Views -> Home folder. Add the following Razor code to the top of the view:

  9. Add the following HtmlHelper code to the end of the view page:

    The complete Index.cshtml should now look like this:

  10. Compile and start the application.

 
 
Call us: +1 704-544-7445 (United States)
 
 

Products

Support

Downloads

Corporate

Buy Now

About Text Control

Founded in 1991, Text Control is an award-winning Visual Studio Industry Partner and leading vendor of word processing and reporting components for Microsoft development technologies. The products help thousands of developers add comprehensive word processing functionality to their applications. Text Control is 100% self-owned and independent of all investor decisions. Customers benefit from these years of experience, large user-base, and at the same time, appreciate developing with a mature, reliable product.

SD Times 100SD Times 100SD Times 100SD Times 100SD Times 100SD Times 100Visual Studio 2015 Launch PartnerVisual Studio 2013 Launch PartnerVisual Studio 2012 Launch PartnerVisual Studio Partner