Tag: mvcsitemapprovider

在mvc5中使用MvcSiteMap创建面包屑

我想在mvc5中使用MvcSiteMap创建面包屑。 我在下面写了代码。 但我希望当我点击第一,第二,……他们的Id传递给View。 但它不起作用。 我做对了吗? //Controller Name=News Home News first //id=1 second //id=2 third // id=3 About [MvcSiteMapNode(Title = “News”, ParentKey = “News”)] public ActionResult News(int id) { ViewBag.id = id; return View(); }

根据用户角色将XML站点地图加载到MvcSiteMapProvider中

我已经安装了MvcSiteMapProvider的v4,现在我想动态加载站点地图。 我的需求很简单 – 根据当前登录的用户角色在每个页面请求上加载XML站点地图,例如。 AdminSiteMap.xml和UserSiteMap.xml 看来这可以做到: 使用带有2个站点地图的asp.net MVCSiteMapProvider v4 https://github.com/maartenba/MvcSiteMapProvider/wiki/Multiple-Sitemaps-in-One-Application 所以基本上你需要使用DI来实现这个目标( 矫枉过正恕我直言 )。 没有 DI可以做到这一点吗? 因此,当我使用ASP Boilerplate( http://www.aspnetboilerplate.com/ )时,我将Castle Windsor作为我的DI。 所以我通过NuGet安装了“MvcSiteMapProvider MVC5 Windsordependency injection配置”。 但是现在当我运行应用程序时,我收到以下错误: SiteMapLoader尚未初始化。 Check the ‘MvcSiteMapProvider_UseExternalDIContainer’ setting in the AppSettings section of web.config. If the setting is set to ‘false’, you will need to call the MvcSiteMapProvider.DI.Composer.Compose() method at the end of […]

MVC5使用MvcSiteMapProvider构建twitter bootstrap菜单

MVC5模板中的默认菜单部分如下所示: @Html.ActionLink(“Home”, “Index”, “Home”) @Html.ActionLink(“About”, “About”, “Home”) @Html.ActionLink(“Contact”, “Contact”, “Home”) @Html.Partial(“_LoginPartial”) _LoginPartial看起来像这样: @using Microsoft.AspNet.Identity @if (Request.IsAuthenticated) { using (Html.BeginForm(“LogOff”, “Account”, FormMethod.Post, new { id = “logoutForm”, @class = “navbar-right” })) { @Html.AntiForgeryToken() @Html.ActionLink(“Hello ” + User.Identity.GetUserName() + “!”, “Manage”, “Account”, routeValues: null, htmlAttributes: new { title = “Manage” }) Log off } } else { […]

Mvcsitemapprovider到单个页面的多个路径

我想让breadcrump导航到同一页面的3条路径。 站点地图位于底部。 我尝试使用属性“类型”和“密钥”,但它没有帮助。 每次当我打开动作ActionDetails时,breadcrump看起来像root> Finished> Action 根据模型的状态在控制器中确定路径的选择。 我现在应该编写自己的DynamicNodeProvider,但我不知道如何从controler将参数传递给Provider。 我无法使用动作注释,因为我现在的动作体模型就像在底部: public ActionResult ActionTabDetails(Guid actionTabGuid) { ActionTab model = actionTabRepo.Get(actionTabGuid, “ActionGroup”); if (model.Status == ActionStatus.New) { //Parameter with I want to pass to the DynamicNodeProvider or select current node } //another conditions return View(“ActionTab/ActionTabDetails”, model); } 我试过了: SiteMap.CurrentNode = SiteMap.Provider.FindSiteMapNodeFromKey(“new”); 但在控制器中只是吸气剂。 我会非常感激你的帮助。 更新: 我用可选参数做了动作: public ActionResult ActionTabDetails(Guid […]

使用多个MvcSiteMaps

我最近遇到了试图使用MvcSiteMapProvider的路障 。 在我的申请中,我有三个不同的领域:着陆,应用和管理。 我目前已经实现了MvcSiteMapProvider,它的工作效果令人惊讶,但我现在要做的是 – 使用Html MvcSiteMap Helper并根据我所在的区域指定不同的地图提供者。 所以,当我: 在“Admin”区域中 – 我想使用名为“AdminSiteMapProvider”的提供程序。 在“应用程序”区域中 – 我想使用名为“AppSiteMapProvider”的提供程序。 我尝试过以下方法: 共享 – > _AppLayout.cshtml @Html.Partial(“_Menu”) 共享 – > _Menu.cshtml @{ if (HttpContext.Current != null && HttpContext.Current.Handler is System.Web.Mvc.MvcHandler) { var handler = HttpContext.Current.Handler as System.Web.Mvc.MvcHandler; var currentArea = handler.RequestContext.RouteData.Values[“area”] ?? string.Empty; if (!string.IsNullOrEmpty(currentArea.ToString())) { @Html.MvcSiteMap(“AppSiteMapProvider”).Menu() } else if (currentArea.ToString() […]