Reply to topic  [ 4 posts ] 
Session lost in asp .net 2.0 after reading an xlsx file 
Author Message

Joined: Fri Mar 06, 2009 8:29 am
Posts: 2
Reply with quote
Post 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.


Fri Mar 06, 2009 9:04 am
Profile

Joined: Fri Feb 03, 2006 12:23 pm
Posts: 199
Location: Brasov, Romania
Reply with quote
Post 
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.


Mon Mar 09, 2009 6:38 am
Profile WWW

Joined: Fri Mar 06, 2009 8:29 am
Posts: 2
Reply with quote
Post 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


Mon Mar 09, 2009 8:12 am
Profile

Joined: Fri Feb 03, 2006 12:23 pm
Posts: 199
Location: Brasov, Romania
Reply with quote
Post 
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


Mon Mar 09, 2009 8:45 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.