The online document viewers have become popular after the grown usage of digital documents, especially in the content management systems. The reason behind this popularity is you can view a variety of document formats without purchasing or installing dedicated software programs. Considering the importance of document viewers, I thought to write an article on how to create a universal document viewer in ASP.NET MVC.

We are going to create an ASP.NET MVC document viewer application that will target the .NET Core framework. For the document rendering at the backend, we’ll use GroupDocs.Viewer for .NET API - a powerful document viewer API which supports over 140 document types including PDF, Word, Excel, PowerPoint, Visio, CAD, Outlook, and many other popular formats.

Why .NET Core?

.NET Core is a valuable addition to the .NET ecosystem by Microsoft. It makes it possible to develop cross-platform applications without any additional efforts required by the developers. This is why I have selected .NET Core to be the targetted framework.

Steps to Create Document Viewer in ASP.NET Core

1. Open Visual Studio and start a new project.

2. Select .NET Core from the project types and ASP.NET Core Web Application from templates.

3. Select Web Application (Model-View-Controller) and click Ok button.

4. Install GroupDocs.Viewer from NuGet.

5. Open Views/Home/Index.cshtml file and replace its content with the following:

6. Open Controllers/HomeController.cs and replace the content of the class with the following code.

7. Append the following styles in the wwwroot/css/site.css file.

8. Build the document viewer application and run in your favorite browser.

ASP.NET Core File Viewer

Download ASP.NET MVC Document Viewer

The source code of the ASP.NET MVC document viewer is open source and available for download.