Skip to main content
A newer version of this page is available. .

Creating a Server Side for the Web Document Viewer

  • 2 minutes to read

This document describes how to create and configure an ASP.NET MVC application as a server-side solution for using the HTML5 Document Viewer in JavaScript:

  1. Create a new ASP.NET MVC project using the Template Gallery and enable the Report Suite to include all the required resources automatically. Refer to Adding a New Report to an ASP.NET MVC Application for a step-by-step tutorial.

    You can provide reporting functionality to an existing MVC application by registering the required extensions as described in Manual Integration of ASP.NET MVC Reporting Extensions Into an Existing Project.

  2. Implement your custom MVC controller by inheriting it from the WebDocumentViewerApiController class. Override the DevExpress.Web.Mvc.Controllers.WebDocumentViewerApiController.Invoke action to allow cross-domain requests:

    using System.Web.Mvc;
    using DevExpress.Web.Mvc.Controllers;
    //...
    
    public class WebDocumentViewerController : WebDocumentViewerApiController {
        //...
        public override ActionResult Invoke() {
            var result = base.Invoke();
            Response.AppendHeader("Access-Control-Allow-Origin", "*");
            return result;
        }
    }
    

    Additionally, override the DevExpress.Web.Mvc.Controllers.WebDocumentViewerApiController.GetLocalization action in the same way if you need to customize localization strings.

  3. Provide a server-side report storage by inheriting from the ReportStorageWebExtension class and overriding its methods.

    using DevExpress.XtraReports.Web.Extensions;
    
    public class MyReportStorage : ReportStorageWebExtension {
       // ...
    }
    

    Register the custom web report storage using the static ReportStorageWebExtension.RegisterExtensionGlobal method on the application’s startup.

    using DevExpress.XtraReports.Web.Extensions;
    
    protected void Application_Start() {
        // ...
        ReportStorageWebExtension.RegisterExtensionGlobal(new MyReportStorage());
    }