This is a migrated thread and some comments may be shown as answers.

Grid Exports Increase Session State Size for every export

6 Answers 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 01 Dec 2014, 04:58 PM
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.

Questions:
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?

Notes:
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
Tim

6 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 01 Dec 2014, 05:19 PM
Hello,

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?

Thanks,
Jayesh Goyani
0
Jeff
Top achievements
Rank 1
answered on 01 Dec 2014, 06:13 PM
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>
11.      
12.    <asp:Button ID="btnExport" runat="server" CssClass="z-btn" OnClick="grdMain_Export" Text="Export" meta:resourcekey="btnExportResource1"
13.        ></asp:Button>
14.</div>


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;
11. 
12.      grdMain.Page.Response.ClearHeaders();
13.      grdMain.Page.Response.Cache.SetCacheability(System.Web.HttpCacheability.Private);
14. 
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
SELECT
     
    DATALENGTH(a.SessionItemLong) /1048576 AS SessionSize_MB,
    a.SessionId,
    a.Created,
    a.Expires
 
 
FROM
    dbo.ASPStateTempSessions AS a
    LEFT OUTER JOIN
    dbo.ASPStateTempApplications AS b
    ON
    SUBSTRING(a.SessionId, 25, 8) =
    SUBSTRING(sys.fn_varbintohexstr(CONVERT(VarBinary,b.AppId)), 3, 8)
WHERE
    (DATALENGTH(a.SessionItemLong) > 0)
ORDER BY SessionSize_MB DESC


0
Jeff
Top achievements
Rank 1
answered on 02 Dec 2014, 10:35 PM
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.

__SESSIONVIEWSTATE8d1dc62aba45da2--System.Web.UI.Pair

__SESSIONVIEWSTATE8d1dc62ae086c21--System.Web.UI.Pair

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




0
Jeff
Top achievements
Rank 1
answered on 03 Dec 2014, 08:42 PM
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?

0
Kostadin
Telerik team
answered on 04 Dec 2014, 12:10 PM
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.

Regards,
Kostadin
Telerik
 

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.

 
0
Jeff
Top achievements
Rank 1
answered on 08 Dec 2014, 08:08 PM
Thanks for your help.  I believe we can close this thread.
Tags
Grid
Asked by
Jeff
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Jeff
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or