我已經使用UrlRouting設置了我的Web表單站點(4.0)。當我去Sitemap/Breadcrumb在默認頁面上沒有顯示Url路由
我的主要問題是與http://Localhost/
,因爲它默認爲http://Localhost/default.aspx在IIS
我 出現在我的麪包屑試圖避免向站點地圖添加另一個元素的路線xml like
<siteMapNode url="~/Home" title="Home" description="Home" aspx="default.aspx">
什麼是最佳的使用方法?
我試圖用xmlSiteMapProvider將它添加到我的路由表&中,看看我是否可以這樣做(這不起作用)。
routes.MapPageRoute("IISDefault", "", "~/Default.aspx");
以下是一些信息。
Routes
routes.MapPageRoute("Default", "Home", "~/Default.aspx");
routes.MapPageRoute("ListAll", "List", "~/ListAll.aspx");
Sitemap
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/Home" title="Home" description="Home">
<siteMapNode url="~/List" title="List All" description="List All" />
</siteMapNode>
</siteMap>
XmlSiteMapProvider
/// <summary>
/// This is where the original sitemap node is overloaded. We get the proper translation from the database.
/// </summary>
/// <param name="sender">This is the sender of the event</param>
/// <param name="e">This is the event arguments</param>
/// <returns>Returns a modified SiteMapNode</returns>
/// <remarks></remarks>
public SiteMapNode SmartSiteMapProvider_SiteMapResolve(object sender, SiteMapResolveEventArgs e)
{
SiteMapNode returnValue = null;
if ((SiteMap.CurrentNode == null))
{
// If we don't find a sitemap node, then we might be working with UrlRouting
returnValue = ProcessRoute(e);
}
return returnValue;
}
private SiteMapNode ProcessRoute(SiteMapResolveEventArgs e)
{
SiteMapNode returnValue = null;
System.Web.Routing.RequestContext rc = HttpContext.Current.Request.RequestContext;
if ((rc != null))
{
System.Web.Routing.RouteBase route = rc.RouteData.Route;
if ((route != null))
{
// Play with the node (Never getting here)
}
}
return returnValue;
}
編輯:我要看看我是否能操縱routeCollection獲得比賽莫名其妙。
感謝沃迪的回答。我將不得不回到這個代碼的東西的擺動。有一陣子了。我試圖把你的url =「〜/」title =「home」放到我的站點地圖中,但無濟於事。當我去Http:// yourdomain時,麪包屑不會出現。 – Lareau 2011-07-11 19:14:37
你期待在麪包屑中看到什麼? ...對於一個主頁技術上沒有面包屑,因爲麪包屑從當前位置顯示回到根的路徑,因此主頁是一種例外......我傾向於硬編碼鏈接到〜/ if我覺得它的相關...事情是...如果你在網頁上,爲什麼你會顯示一個鏈接到主頁? – War 2011-07-12 08:41:05
好點,我總是假設,如果你在主頁上,它會說首頁,但沒有鏈接。從我的快速谷歌搜索,人們只是從主頁中刪除它。感謝您的提示 – Lareau 2011-07-12 10:54:44