Skip to main content

WebDocumentViewerExtension.Bind(CachedReportSourceWeb) Method

Binds the Document Viewer to the report associated with the specified CachedReportSourceWeb object.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v24.1.dll

NuGet Package: DevExpress.Web.Mvc5

Declaration

public WebDocumentViewerExtension Bind(
    CachedReportSourceWeb cachedReportSource
)

Parameters

Name Type Description
cachedReportSource CachedReportSourceWeb

A CachedReportSourceWeb object associated with the report to be displayed.

Returns

Type Description
WebDocumentViewerExtension

A WebDocumentViewerExtension object.

Remarks

The CachedReportSourceWeb object passed as a parameter generates a document for the associated report, caching each generated page. This consumes less memory in comparison to the document generation method used when a report instance is bound directly to the Document Viewer.

// A View with a Document Viewer

@model DevExpress.XtraReports.Web.CachedReportSourceWeb

@Html.DevExpress().WebDocumentViewer(settings => {
  settings.Name = "WebDocumentViewer1";
}).Bind(Model).GetHtml()

// A home controller 

using DevExpress.XtraPrinting.Caching;
using DevExpress.XtraReports.Web.WebDocumentViewer.Native;
//...

public class HomeController : Controller {
  public ActionResult Viewer() {
    var report = new XtraReport1();
    var cachedReportSource = new CachedReportSourceWeb(report);

    return View(cachedReportSource);
  }
} 

Note

The CachedReportSource component cannot be associated with reports that include a PrintableComponentContainer.

Tip

If several Bind method calls are invoked one after another, the Document Viewer displays the report that is specified in the last method call.

By default, a CachedReportSourceWeb object caches a report document to the MemoryDocumentStorage. You can use a file, database or a custom storage instead, so that the Document Viewer can recover its document from the storage after the application pool has recycled. Utilize a file storage by calling the DefaultWebDocumentViewerContainer.UseFileDocumentStorage method. To use a DbDocumentStorage or a custom (DocumentStorage) storage, register your IDocumentStorageProvider object.

If the CachedReportSourceWeb object’s report includes interactive features, they are available to end users only until the application pool is recycled. Using interactive features demands document regeneration. But after application pool is recycled, the document cannot be regenerated, because the initial report is not accessible. To avoid these issues, use the WebDocumentViewerExtension.Bind method overload with a string parameter instead.

See Also