摘要:[ASP.NET]動態修改SiteMap
每個人在做網站節點的時候都有自己的習慣,
以前是習慣用搭配遞迴用DB的方式叫出來,
後來改用.NET裡面的Web.sitemap,
主要是使用XML的方式來定義每個節點,
<!-- ==========權限系統========== -->
<siteMapNode url="" title="權限系統" description="權限系統">
<siteMapNode url="~/account.aspx" title="帳號管理" description="帳號管理">
<siteMapNode url="~/account_modify.aspx" title="修改" description="修改" />
<siteMapNode url="~/account_addnew.aspx" title="新增" description="新增" />
</siteMapNode>
<siteMapNode url="~/login_log.aspx" title="登入記錄" description="登入記錄" />
</siteMapNode>
<!-- ==========權限系統========== -->
<siteMapNode url="" title="權限系統" description="權限系統">
<siteMapNode url="~/account.aspx" title="帳號管理" description="帳號管理">
<siteMapNode url="~/account_modify.aspx" title="修改" description="修改" />
<siteMapNode url="~/account_addnew.aspx" title="新增" description="新增" />
</siteMapNode>
<siteMapNode url="~/login_log.aspx" title="登入記錄" description="登入記錄" />
</siteMapNode>
<!-- ==========權限系統========== -->
就像上例一樣,再搭配SiteMapPath的控制項就可以製作簡易的節點,
可是有一個問題就是遇到用get方式的動態頁面就無法處理,
但其實是可以解決的,在要處理get方式的那個頁面下,加入以下的程式,
























主要是在記憶體中去做動態委任,
當然結束後要做出釋放,否則所有的節點都會一直使用get的方式去連結