ASP.NET 站點地圖(sitemap)簡明教程
更新時間:2012年04月16日 14:44:56 作者:
畢業(yè)設計折騰了近一個月的時間,也將近完工階段。下個禮拜六是論文答辯時間,所以今天晚上就抽空想去弄一下站點地圖。不怕大俠們笑話,我在以前還真沒弄過這些。以前開發(fā)過幾個項目都是系統(tǒng)類,也就沒怎么涉及了
還好,現(xiàn)在有這個機會,就權當自己的筆記吧!。以下講一下最簡單的創(chuàng)建形式。
站點地圖,在每一個網(wǎng)站都必須用的一種技術。它是用來給用戶導航作用的,以便告訴用戶現(xiàn)在的位置。特別是對那些目錄很深的網(wǎng)頁,這種效果就猶為明顯。
比如 天涯社區(qū)>天涯論壇>???..這種形式。
1.新建一個站點地圖(和新建aspx一樣),tour.sitemap.下面是默認情況生成的xml文件。
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="" title="" description="">//一般來說 這里是放第一個 也就是我們上面的例子的“天涯社區(qū)”
<siteMapNode url="" title="" description="" />這里是放置的二級目錄 比如 “天涯論壇”
<siteMapNode url="" title="" description="" />
</siteMap>
現(xiàn)在主要是url的書寫了。url是寫本站點的相對地址。怎么說呢?比如說,你把你的tour.sitemap建立在你主頁的同一層 那么url就寫:~/main.aspx。。這樣就OK了! 換句話說就是以~/開始,表示應用程序的根目錄。這里需要注意點,盡量不要列出相同的地址和帶相關參數(shù)(比如~/DisplayNews/aspx?id=2),這種情況都有可能導致請求失敗。下面是我的書寫格式:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/Main.aspx" title="您現(xiàn)在的位置:首頁" description="網(wǎng)站首頁">
<siteMapNode url="~/DisplayHotelMessage.aspx" title="查看酒店信息" description="查看酒店信息" />
<siteMapNode url="~/DisplayNews.aspx" title="查看新聞" description="查看新聞" />
<siteMapNode url="~/DisplaySelfTour.aspx" title="查看自助游信息" description="查看自助游信息" />
<siteMapNode url="~/GoodLines.aspx" title="查看精品路線" description="查看精品路線" />
<siteMapNode url="~/HainanSituation.aspx" title="海南概況" description="海南概況" />
<siteMapNode url="~/HotelOrder2.aspx" title="酒店預定" description="酒店預定" />
<siteMapNode url="~/ListNews1.aspx" title="新聞列表" description="新聞列表" />
<siteMapNode url="~/Register.aspx" title="用戶注冊" description="用戶注冊" />
<siteMapNode url="~/ViewSpot.aspx" title="景點" description="景點" />
<siteMapNode url="~/DisplayArticle.aspx" title="查看文章" description="查看文章" />
<siteMapNode url="~/DisplayViewSpot.aspx" title="查看景點" description="查看景點" />
<siteMapNode url="~/Hotels.aspx" title="酒店信息" description="酒店信息" />
</siteMapNode>
</siteMap>
其實,到這里就基本OK了。
2.添加站點地圖控件。
運用站點地圖很簡單,就是把<asp:SiteMapPath Runat="Server" ID="SiteMapPath1" ></SiteMapPath>這個服務端控件拉到你需要導航的地方就OK了。
上面就是站點地圖最簡單的運用。當然,這里還有很多的屬性 可以進行相關的設置。
站點地圖,在每一個網(wǎng)站都必須用的一種技術。它是用來給用戶導航作用的,以便告訴用戶現(xiàn)在的位置。特別是對那些目錄很深的網(wǎng)頁,這種效果就猶為明顯。
比如 天涯社區(qū)>天涯論壇>???..這種形式。
1.新建一個站點地圖(和新建aspx一樣),tour.sitemap.下面是默認情況生成的xml文件。
復制代碼 代碼如下:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="" title="" description="">//一般來說 這里是放第一個 也就是我們上面的例子的“天涯社區(qū)”
<siteMapNode url="" title="" description="" />這里是放置的二級目錄 比如 “天涯論壇”
<siteMapNode url="" title="" description="" />
</siteMap>
現(xiàn)在主要是url的書寫了。url是寫本站點的相對地址。怎么說呢?比如說,你把你的tour.sitemap建立在你主頁的同一層 那么url就寫:~/main.aspx。。這樣就OK了! 換句話說就是以~/開始,表示應用程序的根目錄。這里需要注意點,盡量不要列出相同的地址和帶相關參數(shù)(比如~/DisplayNews/aspx?id=2),這種情況都有可能導致請求失敗。下面是我的書寫格式:
復制代碼 代碼如下:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/Main.aspx" title="您現(xiàn)在的位置:首頁" description="網(wǎng)站首頁">
<siteMapNode url="~/DisplayHotelMessage.aspx" title="查看酒店信息" description="查看酒店信息" />
<siteMapNode url="~/DisplayNews.aspx" title="查看新聞" description="查看新聞" />
<siteMapNode url="~/DisplaySelfTour.aspx" title="查看自助游信息" description="查看自助游信息" />
<siteMapNode url="~/GoodLines.aspx" title="查看精品路線" description="查看精品路線" />
<siteMapNode url="~/HainanSituation.aspx" title="海南概況" description="海南概況" />
<siteMapNode url="~/HotelOrder2.aspx" title="酒店預定" description="酒店預定" />
<siteMapNode url="~/ListNews1.aspx" title="新聞列表" description="新聞列表" />
<siteMapNode url="~/Register.aspx" title="用戶注冊" description="用戶注冊" />
<siteMapNode url="~/ViewSpot.aspx" title="景點" description="景點" />
<siteMapNode url="~/DisplayArticle.aspx" title="查看文章" description="查看文章" />
<siteMapNode url="~/DisplayViewSpot.aspx" title="查看景點" description="查看景點" />
<siteMapNode url="~/Hotels.aspx" title="酒店信息" description="酒店信息" />
</siteMapNode>
</siteMap>
其實,到這里就基本OK了。
2.添加站點地圖控件。
運用站點地圖很簡單,就是把<asp:SiteMapPath Runat="Server" ID="SiteMapPath1" ></SiteMapPath>這個服務端控件拉到你需要導航的地方就OK了。
上面就是站點地圖最簡單的運用。當然,這里還有很多的屬性 可以進行相關的設置。
您可能感興趣的文章:
- 在ASP.NET 2.0中操作數(shù)據(jù)之五十一:從GridView的頁腳插入新記錄
- 在ASP.NET 2.0中操作數(shù)據(jù)之五十二:使用FileUpload上傳文件
- 在ASP.NET 2.0中操作數(shù)據(jù)之五十三:在Data Web控件顯示二進制數(shù)據(jù)
- 在ASP.NET 2.0中操作數(shù)據(jù)之五十四:添加新記錄時包含一個文件上傳選項
- 在ASP.NET 2.0中操作數(shù)據(jù)之五十五:編輯和刪除現(xiàn)有的二進制數(shù)據(jù)
- 在ASP.NET 2.0中操作數(shù)據(jù)之五十六:使用ObjectDataSource緩存數(shù)據(jù)
- 在ASP.NET 2.0中操作數(shù)據(jù)之五十七:在分層架構中緩存數(shù)據(jù)
- 在ASP.NET 2.0中操作數(shù)據(jù)之五十八:在程序啟動階段緩存數(shù)據(jù)
- 在ASP.NET 2.0中操作數(shù)據(jù)之五十九:使用SQL緩存依賴項SqlCacheDependency
- 在ASP.NET 2.0中操作數(shù)據(jù)之六十:創(chuàng)建一個自定義的Database-Driven Site Map Provider
相關文章
詳解在ASP.NET Core中使用Angular2以及與Angular2的Token base身份認證
這篇文章主要介紹了詳解在ASP.NET Core中使用Angular2以及與Angular2的Token base身份認證,有興趣的可以了解一下。2016-12-12
asp.net根據(jù)計算機MAC地址限定每臺機子只能領取一次賬號
這里只做簡單演示過程,請根據(jù)您的實際情況作適當修改!另外我的博客只做自己參考查詢方便用,請各位大神不要沒事噴我,知道您的技術高,我是新手正在努力學習當中,謝謝2012-06-06
使用ASP.NET一般處理程序或WebService返回JSON的實現(xiàn)代碼
今天, 將為大家說明如何在 ASP.NET 中使用一般處理程序或者 WebService 向 javascript 返回 JSON2011-10-10

