xtrareports-devexpress-dot-xtrareports-dot-web-dot-webdocumentviewer-86a07b44.md
Associates string values with report instances. Does not operate in asynchronous mode.
Namespace : DevExpress.XtraReports.Web.WebDocumentViewer
Assembly : DevExpress.XtraReports.v25.2.Web.dll
NuGet Package : DevExpress.Web.Reporting.Common
public interface IWebDocumentViewerReportResolver
Public Interface IWebDocumentViewerReportResolver
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 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;
}
}
}
Imports DevExpress.XtraReports.Web.WebDocumentViewer
Imports DevExpress.XtraReports.UI
' ...
Public Class CustomWebDocumentViewerReportResolver
Implements IWebDocumentViewerReportResolver
Public Sub New()
End Sub
Public Function Resolve(ByVal reportUniqueName As String) As XtraReport
Select Case reportUniqueName
Case "Report1"
Return New XtraReport1()
Case "Report2"
Return New XtraReport2()
Case Else
' Try to create a report using the fully qualified type name.
Dim t As Type = Type.GetType(reportUniqueName)
Return If(GetType(XtraReport).IsAssignableFrom(t), CType(Activator.CreateInstance(t), XtraReport), Nothing)
End Select
End Function
End Class
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>();
}
Imports DevExpress.XtraReports.Web.WebDocumentViewer
Private Sub Application_Start(sender As Object, e As EventArgs)
DefaultWebDocumentViewerContainer.Register(Of IWebDocumentViewerReportResolver, CustomWebDocumentViewerReportResolver)()
End Sub
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
IWebDocumentViewerReportResolver Members
ASPxWebDocumentViewer.OpenReport