开发者

How to cache a xml file when I use XmlDataSource1 control?

开发者 https://www.devze.com 2023-02-15 17:01 出处:网络
I u开发者_如何学Gose MenuXML.xml file as datasource of XmlDataSource control in my MasterPage.master, it will be reloaded again and again.

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消