Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

IErrorJsonSerializer Interface

In This Article

Serializes errors that occur on the server to send them to the client.

Namespace: DevExpress.XtraReports.Web.ReportDesigner.Services

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

NuGet Package: DevExpress.Web.Reporting.Common

#Declaration

public interface IErrorJsonSerializer

#Remarks

You can implement and register a custom IErrorJsonSerializerservice and use the service to send error information to the client.

The following code snippet is a sample controller that creates a Report Designer View Model and returns it to the client. If an error occurs, the IErrorJsonSerializer service is used to send the information to the client.

[ApiController]
[Authorize]
[Route("api/[controller]")]
public class ReportDesignerSetupController : ControllerBase {
    [HttpPost("[action]")]
    public object GetReportDesignerModel([FromForm] string reportUrl,
        [FromServices] IReportDesignerModelBuilder reportDesignerModel,
        [FromServices] IErrorJsonSerializer errorSerializer,
        [FromServices] IReportDesignerClientSideModelGenerator modelGenerator) {
        Dictionary<string, object> dataSources = new Dictionary<string, object>();
        //Fill a data source set if needed
        if(something_goes_wrong)
            return errorSerializer.FromError("Try again later");

        reportDesignerModel
            .Report(reportUrl)
            .DataSources(dataSources)
            .DesignerUri("/DXXRDAAA")
            .ViewerUri("/DXXRDVAAA")
            .QueryBuilderUri("/DXXQBAAA")
            .BuildJsonModel();
        var model = reportDesignerModel.BuildModel();
        var modelJson = modelGenerator.GetJsonModelScript(model);
        return Content(modelJson, MediaTypeNames.Application.Json);
    }
}
See Also