How to integrate GroupDocs.Viewer in ASP.NET Core Web application
How to integrate GroupDocs.Viewer in ASP.NET Core Web application
Leave feedback
On this page
This page describes how to develop a simple ASP.NET Core Web application that uses GroupDocs.Viewer for .NET as a rendering engine. The page describes how to create an application and to add required packages using the terminal, but you can do the same with Visual Studio. The following image shows the simplified application diagram:
These commands add the following packages to the application:
GroupDocs.Viewer.UI contains a middleware that serves the client application at the /viewer endpoint that you configure in the next step.
GroupDocs.Viewer.UI.SelfHost.Api contains a middleware with a rendering engine based on GroupDocs.Viewer for .NET. You configure it at the /viewer-api endpoint.
GroupDocs.Viewer.UI.Api.Local.Storage contains an implementation for the storage using a local disk to read and write files uploaded using UI.
GroupDocs.Viewer.UI.Api.Local.Cache contains implementation for the cache storage. The cache stores output files produced by the rendering engine, such as the rendered HTML pages.
Configure middleware
Open the Startup.cs file and add the following lines to ConfigureServices method:
This code registers /viewer middleware that serves client application files and /viewer-api middleware that renders content for the client application.
In the browser, open one of the endpoints listed in the output above and add the /viewer path to see the viewer application in action:
To upload files, click the folder icon or copy your files to the Files directory. You can also specify the path to the directory in the AddLocalStorage extension method.