Saturday, March 24, 2012

Why Session "dies" when i saving xml file

I have DataTable in Session ,

In Global.asax when session starts i'm adding to app DataTable

void Session_Start(object sender,EventArgs e)

{

// Code that runs when a new session is started

Class1 cl =newClass1();

Session.Add(Session.SessionID, cl.getTable());

}

and then i am using it to add data to table :

DataTable a = (DataTable)Session[Session.SessionID] ;

I am also have method that writes an xml file on disk ...

XmlDocument xml = new xmlDocument ();

{

...........................

}

xml.save(@dotnet.itags.org."C:/myxml");

after i saving this file session is gone ... Why ? How can i save my session state ? PLease help !!!

First Check in the web.config that the timeout attribute is set to 20 minutes or more

<sessionState timeout="20"/>

If this doesnt help try to use the below code.

Session[Session.SessionID] = cl.GetTable();

then when u want to retrieve it try

DataTable dt = (DataTable)Session[Session.SessionID];

HC

0 comments:

Post a Comment