Skip to main content

IWebDocumentViewerReportResolver Interface

Associates string values with report instances. Does not operate in asynchronous mode.

Namespace: DevExpress.XtraReports.Web.WebDocumentViewer

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

NuGet Package: DevExpress.Web.Reporting.Common

Declaration

public interface IWebDocumentViewerReportResolver

Remarks

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

Note

The IWebDocumentViewerReportResolver service does not operate in asynchronous mode.

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 locate a match for a 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 application 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
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddSingleton<IWebDocumentViewerReportResolver, CustomWebDocumentViewerReportResolver>();    

var app = builder.Build();

Note

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

See Also