How to cache a xml file when I use XmlDataSource1 control?
I u开发者_如何学Gose MenuXML.xml file as datasource of XmlDataSource control in my MasterPage.master, it will be reloaded again and again. could you tell me how to cache the xml file? Thanks!
XmlDataSource supports caching the file - see EnableCaching property. For example,
<asp:xmldatasource
id="XmlDataSource1"
runat="server"
datafile="MenuXML.xml"
enablecaching="True"
cacheduration="0" />
Above will cache file content till the file is changed. I will suggest you to keep your menus externalized in a separate file (as opposed to putting them directly in markup) as it will reduce clutter (and allow you to switch/change file to change menus if needed).
精彩评论