示例#1
0
        public ActionResult Details(int?id, string seoName)
        {
            Article article = repository.Articles
                              .FirstOrDefault(a => a.ArticleID == id);

            if (seoName != FriendlyUrlHelpers.GetSeoName(article.Title))
            {
                return(RedirectToActionPermanent("Details",
                                                 new { id = id, seoName = FriendlyUrlHelpers.GetSeoName(article.Title) }
                                                 ));
            }
            return(View(article));
        }
        public override IEnumerable <DynamicNode> GetDynamicNodeCollection(ISiteMapNode node)
        {
            using (var db = new EFDbContext())
            {
                foreach (var item in db.Members.ToList())
                {
                    DynamicNode dynamicNode = new DynamicNode();
                    dynamicNode.Title = item.Name;
                    dynamicNode.Key   = "member_" + item.MemberID.ToString();
                    dynamicNode.RouteValues.Add("id", item.MemberID);
                    dynamicNode.RouteValues.Add("seoname", FriendlyUrlHelpers.GetSeoName(item.Name));

                    yield return(dynamicNode);
                }
            }
        }