Skip to main content

WebDocumentViewerExtension.Bind(String) Method

Binds the Document Viewer to the specified report.

Namespace: DevExpress.Web.Mvc

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

NuGet Package: DevExpress.Web.Mvc5

Declaration

public WebDocumentViewerExtension Bind(
    string reportUrl
)

Parameters

Name Type Description
reportUrl String

A String value specifying a report’s unique name.

Returns

Type Description
WebDocumentViewerExtension

A WebDocumentViewerExtension object.

Remarks

A Document Viewer requests an appropriate CachedReportSourceWeb object to generate a document by the specified report’s unique name, when required. The CachedReportSourceWeb object generates a report document caching each generated page. This consumes less memory in comparison to the report generation method used when a report instance is directly passed 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 

public class HomeController : Controller {
  public ActionResult Viewer() {
    return View('myReport');
  }
} 

Implement the ICachedReportSourceWebResolver interface to associate the specified report’s unique name with the CachedReportSourceWeb object that possesses the corresponding report. The following code demonstrates how to register a custom ICachedReportSourceWebResolver.

void Application_Start(object sender, EventArgs e) {
    DefaultWebDocumentViewerContainer.Register<ICachedReportSourceWebResolver, CustomCachedReportSourceWebResolver>();
}

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.

Using this Bind method overload allows the Document Viewer to regenerate documents when using their interactive features after the application pool has recycled, because the initial report can always be found.

By default, the 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.

See Also