Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 23, 2012 08:20 AM by Hua-Jun Li - MSFT
Feb 21, 2012 03:55 PM|LINK
I currently have the function below which I use for pulling data out of an XML file. I use this many times around the site.
The problem is, the XML document rarely changes, but the system has to load it all in every time it wants to use it.
Is there any way of creating a global XML document that is only read in once and just referenced with this function instead?
Dim oContent As New XmlDocument
Return oContent.SelectSingleNode("/xml/Contents/Content[attribute::title='" & sTitle.ToLower & "']").InnerText.Replace("<", "<").Replace(">", ">")
Catch ex As Exception
oContent = Nothing
Feb 21, 2012 04:32 PM|LINK
You can make use of Cache object . Read the xml file from global.asax ( on Application_Start event) and cache it.
Feb 21, 2012 04:34 PM|LINK
Is there any problem using a session instead?
I guess I lied a bit when I said it's not updated regularly - it could potentially be updated every evening.
Feb 23, 2012 08:20 AM|LINK
There is difference between the Cache and session.
The Cache is open to all the users in the application. the session is open to the specific users.
If you store the xmldocument into session, it only be retrieved by the one user.
You should store it for every user.
And in the Cache , you only store once, you can get it in any place.
Please check the following link: