# Creating an ASP.NET MVC DocumentViewer Application With Razor

> This tutorial covers integrating the TX Text Control HTML5 DocumentViewer into an ASP.NET MVC application. It walks through installing TXTextControl.Web.DocumentViewer via NuGet, adding the required assembly references, creating a licenses.licx file, and rendering the viewer in Razor.

- **Author:** Bjoern Meyer
- **Published:** 2020-01-01
- **Modified:** 2026-03-05
- **Description:** Create a simple ASP.NET (MVC) application that uses the HTML5 document viewer.
- **4 min read** (658 words)
- **Tags:**
  - ASP.NET
  - DocumentViewer
  - HTML5
  - Razor
  - Tutorial
- **Web URL:** https://www.textcontrol.com/blog/2020/01/01/creating-an-aspnet-mvc-documentviewer-application-with-razor/
- **LLMs URL:** https://www.textcontrol.com/blog/2020/01/01/creating-an-aspnet-mvc-documentviewer-application-with-razor/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2020/01/01/creating-an-aspnet-mvc-documentviewer-application-with-razor/llms-full.txt

---

API Documentation
-----------------

The full documentation can be found in our online documentation hub *Text Control Docs*:

[TXTextControl.Web.MVC.DocumentViewer](https://docs.textcontrol.com/textcontrol/asp-dotnet/ref.txtextcontrol.web.mvc.documentviewer.namespace.htm)

Video Tutorial
--------------

Create Your Application
-----------------------

1. Make sure that you installed at least a trial version of TX Text Control .NET Server on your development machine:
    
    [Download Trial ](https://www.textcontrol.com/product/tx-text-control-dotnet-server/download/ "Download 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.
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/n/assets/mvc_viewer_1.webp "image")
3. In the next dialog *New ASP.NET Project*, select *Empty* as your project template. Check the checkbox *MVC* to add the folders and core references. Close the dialog with *OK*.
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/n/assets/mvc_viewer_2.webp "image")
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.DocumentViewer*. Find the latest version and click on *Install*.
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/n/assets/mvc_viewer_3.webp "image")
    
    Make sure to update the *Microsoft ASP.NET MVC* packages, if they are available in the *Updates* panel. Close the dialog with *Close*.
5. Click *Add Reference...* from the *Project* main menu. In the opened *Reference Manager*, click on *Browse...* and find the TX Text Control *Assembly* folder that is located in the installation directory of *TX Text Control .NET Server*:
    
    *C:\\Program Files\\Text Control GmbH\\TX Text Control 29.0.NET Server for ASP.NET\\Assembly\\*
    
    Select the 3 files *TXDocumentServer.dll*, *TXTextControl.dll* and *TXTextControl.Server.dll* and confirm with *Add*.
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/n/assets/mvc_viewer_5.webp "image")
6. In the *Solution Explorer*, select the project and choose *Add New Item...* from the *Project* main menu. Select *General -> Text File* as the template, name it *licenses.licx* and confirm with *Add*.
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/n/assets/mvc_viewer_6.webp "image")
    
    Paste the following string into the newly created file:
    
    *TXTextControl.ServerTextControl, TXTextControl.Server, Culture=neutral, PublicKeyToken=6b83fe9a75cfb638*
7. In the *Solution Explorer*, select *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 29.0.NET Server for ASP.NET\\Samples\\Demo\\*
    
    Select the file *demo.rtf* and confirm with *Add*.
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/n/assets/mvc_viewer_4.webp "image")
8. In the *Solution Explorer*, right-click the *Controllers* folder and choose *Add -> Controller...* from the context menu. In the opened dialog *Add Scaffold*, select *MVC 5 Controller - Empty* and confirm with *Add*. Set the name to *HomeController* and insert it by clicking the *Add* button.
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/n/assets/mvc_step5.webp "image")
9. In the *Solution Explorer*, right-click the newly created folder *Home* and choose *Add -> View* from the context menu. Name the view *Index* and confirm with *Add*.
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/n/assets/mvc_viewer_7.webp "image")
10. Open the *Index.cshtml* view from the *Views -> Home* folder. Add the following Razor code to the top of the view:
    
    ```
    @using TXTextControl.Web.MVC.DocumentViewer
    ```
11. Add the following HtmlHelper code to the end of the view page:
    
    ```
    @Html.TXTextControl().DocumentViewer(settings =>
    {
        settings.DocumentPath = Server.MapPath("~/App_Data/Demo.rtf");
        settings.Dock = DocumentViewerSettings.DockStyle.Window;
        settings.IsSelectionActivated = true;
        settings.ShowThumbnailPane = true;
    }).Render()
    ```
    
    The complete *Index.cshtml* should now look like this:
    
    ```
    @using TXTextControl.Web.MVC.DocumentViewer
    
    @{
        ViewBag.Title = "Index";
    }
    
    <h2>Index</h2>
    
    @Html.TXTextControl().DocumentViewer(settings =>
    {
        settings.DocumentPath = Server.MapPath("~/App_Data/Demo.rtf");
        settings.Dock = DocumentViewerSettings.DockStyle.Window;
        settings.IsSelectionActivated = true;
        settings.ShowThumbnailPane = true;
    }).Render()
    ```
12. Compile and start the application.

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [Creating an ASP.NET MVC Application With Razor](https://www.textcontrol.com/blog/2020/01/01/creating-an-aspnet-mvc-application-with-razor/llms.txt)
- [Creating Your First ASP.NET Reporting Application](https://www.textcontrol.com/blog/2020/01/01/creating-your-first-aspnet-reporting-application/llms.txt)
- [Creating an ASP.NET Web Forms AJAX Application](https://www.textcontrol.com/blog/2020/01/01/creating-an-aspnet-web-forms-ajax-application/llms.txt)
- [TextControl.Web: Creating an MVC Application with Razor](https://www.textcontrol.com/blog/2015/05/12/textcontrolweb-creating-an-mvc-application-with-razor/llms.txt)
