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

Document Viewer's Server-Side Configuration (ASP.NET MVC)

  • 2 minutes to read

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

  1. Use the Template Gallery to create a new ASP.NET MVC project. Enable the Report Suite to include all the required resources automatically. Refer to Add a New Report to an ASP.NET MVC Application for a step-by-step tutorial.

    You can also provide reporting functionality to an existing MVC application. To do this, register the required extensions as described in Manual Integration of ASP.NET MVC Reporting Extensions Into an Existing Project.

  2. Create your custom MVC controller and inherit it from the DevExpress.Web.Mvc.Controllers.WebDocumentViewerApiController class. Override the 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;
        }
    }
    

    You can additionally override the WebDocumentViewerApiController.GetLocalization action in the same way if you need to customize localization strings.

  3. Create the ReportStorageWebExtension class’s descendant and override its methods to provide a server-side report storage.

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

    Use the static ReportStorageWebExtension.RegisterExtensionGlobal method at the application’s startup to register the custom web report storage.

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