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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cascader_grCommented:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(url);
Session["xml"] = xmlDoc.OuterXml;

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.