Grid Exports Increase Session State Size for every export

7 posts, 0 answers
  1. Tim
    Tim avatar
    79 posts
    Member since:
    Feb 2008

    Posted 01 Dec 2014 Link to this post

    We found that every time a user clicks the Grid Export, the session size grows.  In our example we have a grid with about 700 records.  Every time the user clicks export the session state size grows another 1mb.  This has become a problem as our session sizes are now growing upto 100mb.  At which point the users are reporting slow downs which we can duplicate with an overly large session state size.

    Is this a known issue?  If so is it fixed in a newer version?
    Is there a method to clear the session values used in the export, after the export is completed?

    We are storing session using the ASPState session database
    We are using an older Telerik version (2013.3.1324) - but are in the process of upgrading.
    All of our grids using the Telerik export are behaving this way.

    Thanks for the help
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 01 Dec 2014 in reply to Tim Link to this post


    As per my knowledge this is not a known issue but could you please provide your code so we can try to resolve this issue?

    Jayesh Goyani
  3. Tim
    Tim avatar
    79 posts
    Member since:
    Feb 2008

    Posted 01 Dec 2014 Link to this post

    Thanks for the quick reply.  Below is the code examples.  We have a grid (grdMain) and below the grid a drop down of export formats and an Export button.  The button click event then simply calls the built in grid export feature (grdMain.MasterTableView.ExportToCSV();)

    Note, you will need to change your web project to manage session from InProc to SQLServer.  This will allow the session data to be stored in an ASPState database (needed for non-sticky load balancing).  The SQL script will help monitor the size of the session.

    Mark Up - Drop Down of Export Options for the grid
    01.<div id="exportToolBar">
    02.    <telerik:RadComboBox ID="ddlExportType" runat="server" meta:resourcekey="ddlExportTypeResource1">
    03.        <Items>
    04.            <telerik:RadComboBoxItem Text="CSV (comma delimited)" Value="CSV"
    05.                runat="server" meta:resourcekey="RadComboBoxItemResource1" />
    06.            <telerik:RadComboBoxItem Selected="True" Text="Excel" Value="EXCEL"
    07.                runat="server" meta:resourcekey="RadComboBoxItemResource2" />
    08.        </Items>
    09.        <CollapseAnimation Duration="200" Type="OutQuint" />
    10.    </telerik:RadComboBox>
    12.    <asp:Button ID="btnExport" runat="server" CssClass="z-btn" OnClick="grdMain_Export" Text="Export" meta:resourcekey="btnExportResource1"
    13.        ></asp:Button>

    Code Behind
    01./// <summary>
    02.  /// Allows the user to export the grid data
    03.  /// </summary>
    04.  /// <param name="sender"></param>
    05.  /// <param name="e"></param>
    06.  protected void grdMain_Export(object sender, EventArgs e)
    07.  {
    08.      grdMain.ExportSettings.ExportOnlyData = true;
    09.      grdMain.ExportSettings.IgnorePaging = true;
    10.      grdMain.ExportSettings.OpenInNewWindow = true;
    12.      grdMain.Page.Response.ClearHeaders();
    13.      grdMain.Page.Response.Cache.SetCacheability(System.Web.HttpCacheability.Private);
    15.      string exportType = ddlExportType.SelectedValue.ToUpperInvariant();
    16.      switch (exportType)
    17.      {
    18.          case "CSV":
    19.              grdMain.MasterTableView.ExportToCSV();
    20.              break;
    21.          case "EXCEL":
    22.              grdMain.MasterTableView.ExportToExcel();
    23.              break;
    24.          default:
    25.              grdMain.MasterTableView.ExportToExcel();
    26.              break;
    27.      }
    28.  }

    SQL Statement to monitor ASPState Session Size
        DATALENGTH(a.SessionItemLong) /1048576 AS SessionSize_MB,
        dbo.ASPStateTempSessions AS a
        dbo.ASPStateTempApplications AS b
        SUBSTRING(a.SessionId, 25, 8) =
        SUBSTRING(sys.fn_varbintohexstr(CONVERT(VarBinary,b.AppId)), 3, 8)
        (DATALENGTH(a.SessionItemLong) > 0)
    ORDER BY SessionSize_MB DESC

  4. Tim
    Tim avatar
    79 posts
    Member since:
    Feb 2008

    Posted 02 Dec 2014 Link to this post

    The team started to track the objects placed in session during the grid export and page navigation.  What we found were session values being added with the prefix SessionViewState.  2 examples below from the export code sample above.



    Any insight as to what these session values are?  If they are truly viewstate, why are they in session?

  5. Tim
    Tim avatar
    79 posts
    Member since:
    Feb 2008

    Posted 03 Dec 2014 Link to this post

    I am going to pull back from our original assumption that this is tied to the export.  What the team has found is that every page postback is dumping (what we assume is ViewState) into the session.  The export button was just doing a post back - which is the real bugger.

    So what we have found is that every post back or new page request adds multiple ViewState values to session.  Over time these session values accumulate and bloat out the session as it holds ViewState for every past page request.

    Any suggestions on how to clear/garbage-collect these old ViewState values being stored for the whole lifespan of the user's session?

  6. Kostadin
    Kostadin avatar
    1733 posts

    Posted 04 Dec 2014 Link to this post

    Hello Tim,

    I am afraid we are not aware of such issue. Note that RadControls do not store any information in the session unless RadChart which stores the image in order to avoid its recalculation on each postback. I would recommend you to examine your project and check for a code which might stores the viewstate or any other information in a session. Also I would appreciate if you can replicate the issue in a small runnable sample in order to investigate it further.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  7. Tim
    Tim avatar
    79 posts
    Member since:
    Feb 2008

    Posted 08 Dec 2014 Link to this post

    Thanks for your help.  I believe we can close this thread.
Back to Top