EasyXLS http://forum.easyxls.com/ |
|
Session lost in asp .net 2.0 after reading an xlsx file http://forum.easyxls.com/viewtopic.php?f=4&t=1069 |
Page 1 of 1 |
Author: | luga23 [ Fri Mar 06, 2009 9:04 am ] |
Post subject: | Session lost in asp .net 2.0 after reading an xlsx file |
Hi, I'm using EasyXLS .NET reader ver. 6.2 I have a simple page which stores a session variable when a page loads, in the page there is a button that reads an xlsx file and shows how many rows the file has, it works fine but after that if I try to get the value in the session, the session variable is not there any more. I'm using the next code to get the number of rows. ExcelDocument doc = new ExcelDocument(); if (doc.easy_LoadXLSXFile(Request.PhysicalApplicationPath + "lugatest.xlsx")) { this.Label2.Text = ((ExcelWorksheet)doc.easy_getSheetAt(0)).easy_getExcelTable().RowCount().ToString(); } doc.Dispose(); Am I missing something? Regards. |
Author: | daniela [ Mon Mar 09, 2009 6:38 am ] |
Post subject: | |
The error is not from EasyXLS code. You may try to comment ONLY the code that you sent us and let us know if the error persist. |
Author: | luga23 [ Mon Mar 09, 2009 8:12 am ] |
Post subject: | Session lost in asp .net 2.0 after reading an xlsx file |
Hi Daniela, as you suggested I commented the lines that use EasyXLSX and the session variable works fine. however when I uncommnent those lines and I test reading a xlsx file the session is lost. The next code is a simple example about my problem: public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Session.Add("mivariable","session variable is here!"); } } //reading xlsx file protected void Button2_Click(object sender, EventArgs e) { ExcelDocument doc = new ExcelDocument(); if (doc.easy_LoadXLSXFile(Request.PhysicalApplicationPath + "lugatest.xlsx")) { this.Label2.Text = "Number of rows detected: " + ((ExcelWorksheet)doc.easy_getSheetAt(0)).easy_getExcelTable().RowCount().ToString(); } doc.Dispose(); } //doing a simple postback protected void Button1_Click(object sender, EventArgs e) { //nothing here just for testing } //reading session stored protected void Button3_Click(object sender, EventArgs e) { if (Session["mivariable"] != null) this.Label1.Text = Session["mivariable"].ToString(); else this.Label1.Text = "There is nothing in session"; } } If I click on Button3 when the page is loaded I can see the content of the session variable in the label, then if I click on Button1 which does a postback and then click on Button3 again, the content of the session variable is shown correctly in the label, but if I click on Button2 which reads a xlsx file and finally click on Button3 the label shows "there is nothing in session" message. Any idea about why this is happening? Regards |
Author: | daniela [ Mon Mar 09, 2009 8:45 am ] |
Post subject: | |
You reached a .NET 2.0 defect. If a folder is deleted, the session variables are lost. The xlsx file is a zip file. EasyXLS use a temporary folder to unzip the files. After the load of the file, the folder is deleted. You have 3 alternatives: 1. Use .NET 1.1, instead of 2.0 2. Use an xls file instead of an xlsx file (if possible) 3. Change the session mode to SQLServer, instead of InProc The following link might help you: http://forums.asp.net/p/998370/1311015.aspx |
Page 1 of 1 | All times are UTC - 4 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |