MVC5 использует MvcSiteMapProvider для создания загрузочного меню Twitter
Раздел меню по умолчанию в шаблоне 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" })
<a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>
}
}
else
{
@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })
@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })
}
Так что я могу заменить код
@Html.ActionLink("Home", "Index", "Home")
@Html.ActionLink("About", "About", "Home")
@Html.ActionLink("Contact", "Contact", "Home")
всего одной строкой:
@Html.MvcSiteMap().Menu(false)
Эта строка будет производить это:
@Html.ActionLink("Home", "Index", "Home")
@Html.ActionLink("About", "About", "Home")
@Html.ActionLink("Contact", "Contact", "Home")
//how to put _LoginPartial here!
Так что вопрос в том, как я могу сделать@Html.Partial("_LoginPartial")
внутри меню создано?MvcSiteMapProvider