我在我的应用程序中使用 twitter bootstrap 包来进行应用程序布局。
我主要使用 _BootstrapLayout.basic.cshtml 作为默认布局。
@using System.Web.Optimization
@using BootstrapSupport
@using NavigationRoutes
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>@ViewBag.Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="@Styles.Url("~/content/css")" rel="stylesheet"/>
@RenderSection("head", required: false)
@RenderSection("jtable", required:false)
@Html.Partial("_html5shiv")
@* favicons and touch icons go here *@
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#" title="change in _bootstrapLayout.basic.cshtml">Sorama</a>
<div class="nav-collapse collapse">
<ul class="nav">
@Html.Navigation()
</ul>
</div>
</div>
</div>
</div>
<div class="container">
@Html.Partial("_alerts")
@Html.Partial("_validationSummary")
@RenderBody()
<hr>
<footer>
<p>© Sorama @System.DateTime.Now.ToString("yyyy")</p>
</footer>
</div>
@Scripts.Render("~/js")
@RenderSection("Scripts", required: false)
</body>
</html>
this gives me a page with nav bar
如何在导航栏的右上角向登录用户显示欢迎消息?像欢迎 ABC 之类的东西!旁边还有一些注销选项?
我唯一知道的是我可以从中获取当前用户的名称User.Identity.Name
但我不知道如何让它出现在菜单栏上。
我找不到可以帮助我的东西,所以我想也许我可以在这里得到它。
Edit: After @User.Identity.Name
being added in view
I added above mentioned code after <ul>
tag with @html.navigation
and this is what I get
我在菜单栏上看到了欢迎演示(在个人资料旁边,很难看到),但它与我预期的完全不同。
可以做些什么吗DefaultRouteConfig
由 Bootstrap 提供?
public class LayoutsRouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapNavigationRoute<ModuleController>("Module", c => c.Index());
routes.MapNavigationRoute<AccountController>("Hardware", c => c.Login());
routes.MapNavigationRoute<LayoutsController>("Profile", c => c.Starter())
.AddChildRoute<LayoutsController>("Change Password", c => c.Marketing())
.AddChildRoute<AccountController>("Add User", c => c.Register())
.AddChildRoute<LayoutsController>("Logout", c => c.SignIn())
;
}
}