WebForms ReportViewer and SessionState serialization

9 posts, 0 answers
  1. Jeff
    Jeff avatar
    6 posts
    Member since:
    Dec 2015

    Posted 22 Mar Link to this post

    We are using the WebForms report viewer control on an .aspx page.  We are trying to modify our site to use a State Server session state model, so all of our session items need to be serializable.. we've successfully made our objects serializable, but we are running in to a Serialization error on the ReportViewer page, and can't get to the bottom of it, because the error is thrown by external code... 

    Our report viewer page ends up throwing 

    Exception:Caught: "Invalid name character in 'List`1'. The '`' character, hexadecimal value 0x60, cannot be included in a name." (System.ArgumentException)
    A System.ArgumentException was caught: "Invalid name character in 'List`1'. The '`' character, hexadecimal value 0x60, cannot be included in a name."

    Which leads to 

    A System.Web.HttpException was caught: "Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode."

     

    None of our code is placing anything in to Session for the Report ... the code works fine for "InProc" session, which leads us to surmise that the Report Viewer control is utilizing Session State somewhere.  How can we utilize the Report Viewer control in a Serializable manner?

     

    Thanks

     

    Jeff

     

  2. Jeff
    Jeff avatar
    6 posts
    Member since:
    Dec 2015

    Posted 22 Mar in reply to Jeff Link to this post

    I have found some of these items in state that I don't believe are things we placed in:

    2f091905561c4b4b9c82a06ba1899770

    Telerik.Reporting.LiveInstances

    2f091905561c4b4b9c82a06ba1899770Culture

    2f091905561c4b4b9c82a06ba1899770UICulture

    2f091905561c4b4b9c82a06ba1899770History

    c14b9b44-f58e-452f-86b7-30c5aab698cd

    2f091905561c4b4b9c82a06ba1899770ReportSource

  3. DevCraft banner
  4. Jeff
    Jeff avatar
    6 posts
    Member since:
    Dec 2015

    Posted 22 Mar in reply to Jeff Link to this post

    So, it looks like the Telerik.Reporting.LiveInstance item is causing the error that I posted:

    Telerik.Reporting.LiveInstances - System.Collections.Generic.List`1[System.String]

  5. Jeff
    Jeff avatar
    6 posts
    Member since:
    Dec 2015

    Posted 22 Mar in reply to Jeff Link to this post

    It also looks like this Item is troublesome:

    2f091905561c4b4b9c82a06ba1899770Actions - System.Collections.Generic.List`1[Telerik.Reporting.Processing.IdActionInfo]'

    How can we adjust how the reporting control interacts with session?

  6. Stef
    Admin
    Stef avatar
    3050 posts

    Posted 25 Mar Link to this post

    Hi Jeff,

    The old ASP.NET WebForms ReportViewer uses the ASP.NET Session and ASP.NET Cache to preserve resources and the processed report between requests. The report and its data source must conform to all rules listed in Design Considerations for Out-proc Session State.

    On a side note, switching to the HTML5 Viewer is recommended as the old ASP.NET WebForms ReportViewer is obsolete as of Q3 2015. Details how the HTML5 Viewer looks and works are available in the overview article. Details how to start using are available in How To: Use HTML5 Report Viewer in an application.


    I hope this information is helpful.


    Regards,
    Stef
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  7. Jeff
    Jeff avatar
    6 posts
    Member since:
    Dec 2015

    Posted 25 Mar in reply to Stef Link to this post

    I've read the Article for design for out-of-proc session reports.  Our reports do follow those guidelines. They do not utilize Events, the classes that serve as their data-sources, and the reports have a public default constructor.

    We are using the Telerik Reporting Q3 2014 SP1 version of the viewer.  This website has been in use for some time, and we did investigate moving things to the HTML5 viewer, but it seems that our reports would be in need of some significant re-work to make them work with that control (or are there example of using .cs reports on the HTML5 viewer that you could point me to that would function with reports where we currently create them via code like:  Telerik.Reporting.Report rpt = new Reports.MyCSReportClassName(myListofDataClasses) ?)

     

  8. Stef
    Admin
    Stef avatar
    3050 posts

    Posted 25 Mar Link to this post

    Hello Jeff,

    In the current project with the old ASP.NET WebForms viewer, there must be an IEnumerable collection set as a data item's DataSource or report parameter's available values. The whole report object will be serialized in the session. The used collection cannot be serialized in the ASP.NET Session which causes the error.

    About switching to the HTML5 Viewer, please check the overview article for details how it works. The How to: Set ReportSource for Report Viewers article contains details how to set the viewer's report source in order to request document from the server. And about creating reports at run-time or customizing them, please check how to use a custom report resolver for the Reporting REST service.

    Regards,
    Stef
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  9. Jeff
    Jeff avatar
    6 posts
    Member since:
    Dec 2015

    Posted 07 Apr in reply to Stef Link to this post

    Our data source is a Serializeable object.. it is not a itself a IEnumerable object, it is an object with a handful of string properties (things like a date range, a report title value etc..) and a property that is an IEnumerable list.. And the object itself is serializeable.  Is the requirement to use this control truly that the data source is a IEnumerable list? or simply that the data source needs to be serializable?

    I've attempted to read through the documentation on the HTML5 control more, but I still don't see how we pass the object for the Data to the report. Are there any Examples or documentation for passing a Data object to the Report using the HTML5 report viewer? or is this simply not possible with that control?

  10. Stef
    Admin
    Stef avatar
    3050 posts

    Posted 11 Apr Link to this post

    Hello Jeff,

    With the old ASP.NET WebForms ReportViewer and out-proc session state mode, the data source has to be binary serializable:
    As the data sources are kept in the session state, it is highly recommended to use the built-in Data Source Components. As a last resort you can use the NeedDataSource event to populate the report with data. Otherwise the session state will either become very large, especially when using large datasets or the data for the report will not be serialized at all if it cannot be binary serialized/deserialized (e.g. business objects, anonymous types, data adapters, etc.). You should restrain from setting an instance of your business object directly as a data source, as it would be serialized multiple times into the session.
    Full details are available in Design Considerations for Out-proc Session State.


    With the HTML5 Viewer, all modifications of the report should happen on the server. Thus data can be passed in the data items' NeedDataSource events - Using Report Events.
    Or you can use a custom report resolver for the Reporting REST service, which allows you to resolve in code which report to be displayed and with what settings. Please consider the example in Changing a parameter's datasource connection string at runtime.


    Regards,
    Stef
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft banner