MVC Sitemap Provider —在面包屑跟踪中维护URL参数

|| 我正在使用http://mvcsitemap.codeplex.com/中的MvcSiteMapProvider为我的项目创建面包屑跟踪。我有一些网址,需要传递一个ID才能为适当的用户提供信息,例如http:// localhost:52306 / Home / User?ID = 101101 当我进一步导航到站点地图时(例如http:// localhost:52306 / Home / User / Details?ID = 101101),并尝试使用面包屑链接将我带回到\“ User \”页面,即ID参数迷路了。我尝试将SiteMapPreserveRouteData属性添加到操作方法中,但是它们似乎没有做任何事情。有没有一种简单的方法可以确保保留此ID信息?我认为应该使用SiteMapPreserveRouteDataAttribute来做到这一点,所以我对这个属性做错了吗?我的方法如下所示:
[SiteMapPreserveRouteData]
public ActionResult User()
{
  //code
}
如果您需要我提供更多信息,请告诉我。     
已邀请:
        我这样做的方法是,使用原始的mvc站点地图帮助程序源来渲染面包屑,并将其更改为处理参数(尽管在我的项目中,我们仅显示要过滤的参数,并允许用户单击它们以松散其他过滤参数,如下所示)节点文本非常幼稚的实现,仅是一个示例如何实现):
   private static string SiteMapText(this MvcSiteMapHtmlHelper helper, SiteMapNode node, string linkCssClass, IDictionary<string, object> htmlAttributes)
    {
        var extraAttributes = new StringBuilder();
        foreach (var attribute in htmlAttributes)
        {
            extraAttributes.Append(\" \" + attribute.Key + \"=\\\"\" + attribute.Value + \"\\\"\");
        }            

        string spanHtml;
        var paramDictionary = helper.HtmlHelper.ViewContext.RequestContext.HttpContext.Request.Params.ToDictionary();
        var queryParams = paramDictionary.Select(x => string.Format(\"{0}:{1}\", x.Key, x.Value));

        // here you add request parameters
        var title = helper.HtmlHelper.Encode(string.Format(\"{0} ({1})\", node.Title, string.Join(\";\", queryParams)));

        if (!string.IsNullOrEmpty(linkCssClass))
        {
            spanHtml = string.Format(\"<span><span class=\\\"{0}\\\"{1}>{2}</span>\", linkCssClass, extraAttributes, title);
        }
        else
        {
            spanHtml = string.Format(\"<span><span{1}>{0}</span>\", title, extraAttributes);
        }

        return spanHtml;
    }
以相同的方式,您可以调整SiteMapLink方法,以包括当前节点的请求参数。     
        根据MVCSiteMapperProvider上的该线程,您不能使用查询字符串。它忽略查询字符串,仅使用路由数据。 查询字符串和MVCSiteMapper 您是否考虑过创建一些新的路由而不是使用查询字符串?     

要回复问题请先登录注册