Setup Doconut in .NET Framework 4.7

Web.config file

The viewer requires HttpHandler to be registered via web.config file. Depending on your IIS version it can be done using the following section defined in web.config (also shown in our sample Asp.Net project’s web.config file)

Below IIS 7

<httpHandlers>
  <add verb="GET,POST" path="DocImage.axd" type="Doconut.DocImageHandler, Doconut" />
</httpHandlers>
For Webfarm, use this configuration
<httpHandlers>
  <add verb="GET,POST" path="DocImage.axd" type="Doconut.DiskImageHandler, Doconut" />
</httpHandlers>

IIS 7 and above

<httpHandlers>
  <add name="DocImage" verb="GET,POST" path="DocImage.axd" type="Doconut.DocImageHandler, Doconut" />
</httpHandlers>
For Webfarm, use this configuration
<httpHandlers>
  <add name="DocImage" verb="GET,POST" path="DocImage.axd" type="Doconut.DiskImageHandler, Doconut" />
</httpHandlers>

Register in ASPX pages

This line registers the "Doconut" assembly with the specified namespace and tag prefix, enabling you to utilize Doconut controls and functionalities within your ASP.NET application.

<%@ Register Assembly="Doconut" Namespace="Doconut" TagPrefix="asp" %>

Add Viewer control in the ASPX page

Include the following line of code to add the viewer control into your project.

<asp:Viewer ID="ctlDoc" runat="server"/>

Add Doconut Namespaces

In your project, add the following usings:

using Doconut;
using Doconut.Configs;
using Doconut.Formats;
using Doconut.Clouds;

Instantiate Viewer object

This line instantiates a new instance of the Viewer class, allowing you to create a viewer object within your code.

var viewer = new Viewer { ID = "ctlDoc", BasePath = "/" }

Setup a config object

Per example, this line initializes a new PdfConfig object named "config" with specific configurations for handling PDF documents.

var config = new PdfConfig { DefaultRender = true, ExtractHyperlinks = true };

Open your document

This line invokes the "OpenDocument" method of the viewer object, passing the path of the document file located on the server and the previously configured PdfConfig object as parameters.

var token = viewer.OpenDocument(filename, config);