xml.save vs storing xml in a session variable...if the latter, how?

Hi,

I am retrieving an xml from a URL and then I need to make it accesible to different pages within my asp.net application.
I have come accross two potential ways of doing this. One is by storing the file in disk using xml.save.
The other is by storing the xml in a session variable.

The first option I have figured out how to do it. But I am not sure if that option is better than the second one. As for the second one, I have managed to store the xml in a session variable,
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(url);
Session["xml"] = xmlDoc.InnerXml;

but cannot read it in the receiving page, because
xmlDoc.InnerXml = Session["xml"];
is giving error.

Thanks in advance for making this site a value added resource.
robespierre_2010Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
cascader_grConnect With a Mentor Commented:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(url);
Session["xml"] = xmlDoc.OuterXml;

//And then...
xmlDoc.Load(Session["xml"].tostring);
0
 
robespierre_2010Author Commented:
hi.

xmlDoc.Load(Session["xml"].ToString());

this does not work because

Session["xml"].ToString()

is empty in the receiving page.

0
 
numberkruncherCommented:
Just a thought that I had whilst reading your question, does the entire XML file actually need to be stored in each session?

Perhaps just the URL needs to be stored (preferably in relative form for security reasons). The XML file could then simply be reloaded by URL each time a request is made. Unless, of course, the XML is dynamically tailored for the current session/user.

With regards to your empty value problem, is the second page being loaded in a separate session, I have experienced this when using multiple web browser instances?
0
 
robespierre_2010Author Commented:
hi.
the problem with calling the url each time is that the xml obtained may vary as the underlying data change with time. so it is necessary to stor the xml.

the second page is loaded in the same session(and same browser instance). there is a session variable that stores only a string and that is being passed correctly from one page to the other. but the xml isn't.

regards.
0
All Courses

From novice to tech pro — start learning today.