Good patterns practices for C1ReportViewer.RegisterDocument 2025v2 399

Posted by: enrique.pv-ext on 24 March 2026, 11:20 am EST

  • Posted 24 March 2026, 11:20 am EST - Updated 24 March 2026, 11:21 am EST

    Hi,

    Migrate from 2010v1 to 2025v2 399 in ASP.NET WebForms NET Framework 4.8.1.

    Using C1ReportViewer from C1.Web.Wijmo.Controls.48.dll

    Changes C1WebReport to C1ReportViewer control.

    I use C1ReportViewer control (viewer mode) in a C1Dialog, in aspx with UpdatePanels, GridView (RowCommand), open C1Dialog within Report viewer

      protected void C1GridView1_RowCommand(object sender, C1GridViewCommandEventArgs e)
      {
          if (e.CommandName == "ShowReport")
          {
    
      var report = ReportHelper.BuildFinalLiquidationReport(
              int.Parse(idFinalLiquidation),           shiftsToLiquidateList, ...);
    
    
      // Enviar el archivo temporal al report viewer
      string tempFolder = Server.MapPath("~/_Reports/Temp");
      string fileReport = Path.Combine(tempFolder, "report.xml");
    
      report.Save(fileReport);
      //report.DataSource
    
      var path = $"{HttpContext.Current.Request.PhysicalApplicationPath}/{GetConfigurationParameter(ConfigurationParamType.ReportsPath)}/CollectionReports/FinalLiquidation.xml";
    
      //report.Load(Path.GetFullPath(path), "report");
      //report.ReportName = "report";
    
      C1ReportViewer.RegisterDocument("report", () => report);
    
      ReportViewer.ReportName = "report";
      ReportViewer.ReportsFolderPath = "~/_Reports/Temp";
      //ReportViewer.FileName = "~/_Reports/Files/CollectionReports/FinalLiquidation.xml";
      ReportViewer.FileName = "report";
      ReportViewer.FullScreen = false;
      ReportViewer.Zoom = "100%";
      //ReportViewer.Zoom = "Fit Width";
    
      // Mostrar el diálogo
      ReportDialog.ShowOnLoad = true;
    
      // ===============================
      // 3. Refrescar Grid como antes
      // ===============================
    
    UpdatePanelGrid.Update();
    

    which are good patterns and practices using C1ReportViewer.RegisterDocument ?

    use UnRegisterDocument ? IsDocumentRegistered ?

    HasCachedDocument ? ClearCachedDocument ??

        public static C1ReportV48.C1Report BuildFinalLiquidationReport(
                int finalLiquidationId,
                IList<LiquidatedShift> liquidatedShiftList,...)
        {
                IReportsService rptService = new ReportConmexService();
                var report = C1ReportViewer.CreateC1Report();
    
                var path = $"{HttpContext.Current.Request.PhysicalApplicationPath}/{GenericService.Instance.GetConfigurationParameter(ConfigurationParamType.ReportsPath)}/CollectionReports/FinalLiquidation.xml";
                report.Load(Path.GetFullPath(path), "report");
                report.ReportName = "report";
    
                // === MAIN DATA ===
                DataView dvShift = (DataView)rptService.GetFinalLiquidationReport(LoggedUser.LanguageId, OPERATOR_LIQUIDATION, finalLiquidationId.ToString(), PLAZA_ID);
    
                // === Logo ===
                report.Fields["logo"].Picture = $"{HttpContext.Current.Request.PhysicalApplicationPath}/{GenericService.Instance.GetConfigurationParameter(ConfigurationParamType.LogoPath)}";
                report.Fields["logo"].PictureScale = C1ReportV48.PictureScaleEnum.Scale;
    
       // === Page layout ===
       var settings = report.C1Document.PageLayout.PageSettings;
    
       settings.TopMargin = new c1v48::C1.C1Preview.Unit(Convert.ToDouble(GenericService.Instance.GetConfigurationParameter(ConfigurationParamType.ReportsTopMargin)), c1v48::C1.C1Preview.UnitTypeEnum.Mm);
       settings.BottomMargin = new c1v48::C1.C1Preview.Unit(Convert.ToDouble(GenericService.Instance.GetConfigurationParameter(ConfigurationParamType.ReportsBottomMargin)), c1v48::C1.C1Preview.UnitTypeEnum.Mm);
       settings.LeftMargin = new c1v48::C1.C1Preview.Unit(Convert.ToDouble(GenericService.Instance.GetConfigurationParameter(ConfigurationParamType.ReportsLeftMargin)), c1v48::C1.C1Preview.UnitTypeEnum.Mm);
       settings.RightMargin = new c1v48::C1.C1Preview.Unit(Convert.ToDouble(GenericService.Instance.GetConfigurationParameter(ConfigurationParamType.ReportsRightMargin)), c1v48::C1.C1Preview.UnitTypeEnum.Mm);
    
       settings.PaperKind = System.Drawing.Printing.PaperKind.A4;
    
       // === MAIN DATASOURCE ===
       report.DataSource.Recordset = dvShift;
    
       return report;

    any suggestions, recommendations, good practices ?

  • Posted 26 March 2026, 4:16 am EST

    Hello Enrique,

    As per our investigation, the report gets cached and is returned when the same DocumentName is used to get the report even if a new report is registered on that DocumentName. We also tried to clear cache using ‘ClearCachedDocument()’ and unregister report using ‘UnRegisterDocument()’, but they do not seem to be working.

    We have shared these observations with the development team for further insights. [Internal Tracking ID: C1WEB-30441]

    We’ll get back once we have more updates.

    In the meantime, you can use different DocumentName for each of your report as follows:

    C1ReportViewer.RegisterDocument($"RowReport-{rowId}", () => report);
    ReportViewer.FileName = $"RowReport-{rowId}";

    Please refer to the attached sample for implementation. (see GridView_ReportViewer_Dialog_Sample_Mod.zip)

    Regards,

    Uttkarsh.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels