A newer version of this page is available. Switch to the current version.

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.v18.2.dll

Declaration

public WebDocumentViewerExtension Bind(
    CachedReportSourceWeb cachedReportSource
)
Public Function Bind(
    cachedReportSource As CachedReportSourceWeb
) As WebDocumentViewerExtension

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