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

IWebDocumentViewerReportResolver Interface

Associates string values with report instances.

Namespace: DevExpress.XtraReports.Web.WebDocumentViewer

Assembly: DevExpress.XtraReports.v20.2.Web.dll

NuGet Package: DevExpress.Web.Reporting.Common

Declaration

public interface IWebDocumentViewerReportResolver

Remarks

The built-in report resolver uses the report’s unique name to load a report from the report storage.

To implement a custom report resolver, create a class and register it.

Create a Class

Create a class that implements the IWebDocumentViewerReportResolver interface.

The following example demonstrates a custom resolver that attempts to find a match for the report name. If no match is found, it attempts to instantiate a type with the specified name.

using DevExpress.XtraReports.Web.WebDocumentViewer;
using DevExpress.XtraReports.UI;
// ...

public class CustomWebDocumentViewerReportResolver : IWebDocumentViewerReportResolver {
    public CustomWebDocumentViewerReportResolver() { }

    public XtraReport Resolve(string reportUniqueName) {
        switch (reportUniqueName) {
            case "Report1":
                return new XtraReport1();
            case "Report2":
                return new XtraReport2();
            default:
                // Try to create a report using the fully qualified type name.
                Type t = Type.GetType(reportUniqueName);
                return typeof(XtraReport).IsAssignableFrom(t) ?
                    (XtraReport)Activator.CreateInstance(t) :                
                    null;                                             
        }      
    }
}

Register a Resolver

Register a custom report resolver at the application’s startup.

  • ASP.NET Web Forms and ASP.NET MVC

    using DevExpress.XtraReports.Web.WebDocumentViewer;
    
    void Application_Start(object sender, EventArgs e) {
        DefaultWebDocumentViewerContainer.Register<IWebDocumentViewerReportResolver, CustomWebDocumentViewerReportResolver>();
    }
    
  • ASP.NET Core

    using DevExpress.XtraReports.Web.WebDocumentViewer;
    
    public void ConfigureServices(IServiceCollection services) {
        // ...
        services.AddSingleton<IWebDocumentViewerReportResolver, CustomWebDocumentViewerReportResolver>();
    }
    

Note

Review the Open a Report in ASP.NET Core Application help topic for more information.

See Also