我已经使用UrlRouting设置了我的Web表单站点(4.0)。 当我访问以下链接时,我的面包屑会出现
我的主要问题在于 http://Localhost/
因为它在IIS中默认为http://Localhost/default.aspx
我试图避免向站点地图xml添加另一个元素,例如:
<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以某种方式进行匹配。