我正在奥特森蒂语工作,在成功标识之后,我想在纳夫酒吧展示用户名称。 我使用了静态的现场来保存用户名称并用@显示用户名称。 观点Bag
,问题在于路线改变观点变得无效。 这就要求我更新在每个行动中都有一个静态的野心。 因此,如果不在每项行动中更新意见书,还没有任何其他方式这样做? 任何避免出现密码重复的方法都将受到赞赏。
主计长: Dash Service
public async Task<IActionResult> Index()
{
// Get session
string id = httpContextAccessor.HttpContext.Session.GetString("AccoountId");
// Find user | loggedin user
var account = await userService.GetAccount(id);
Profile.Firstname = account.Firstname;
Profile.Lastname = account.Lastname;
ViewBag.Name = $"{Profile.Firstname.ToString().Substring(0, 1)}.{Profile.Lastname}";
var report = userService.GetReportAsync().Result;
if (report == null)
return RedirectToAction("UnAuthorize", "Home");
return View(report);
}
观点:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - Contact Manager Portal</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
$("#openModalBtn").click(function () {
$("#myModal").modal( show );
});
});
</script>
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
@*<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">ContactsManager.Web</a>*@
<div>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Reports</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="User" asp-action="Index">Clients</a>
</li>
</ul>
</div>
</div>
<div style="gap:.9em; display:flex">
@using (Html.BeginForm("Search", "User", FormMethod.Get))
{
<div class="input-group mb-6 d-flex" style="gap:.6em">
<input type="text" class="form-control" name="query" placeholder="Search Contacts">
<button type="submit" class="btn btn-outline-secondary">Search</button>
</div>
}
<button id="openModalBtn" type="button" class="btn btn-outline-primary">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cloud-plus" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 5.5a.5.5 0 0 1 .5.5v1.5H10a.5.5 0 0 1 0 1H8.5V10a.5.5 0 0 1-1 0V8.5H6a.5.5 0 0 1 0-1h1.5V6a.5.5 0 0 1 .5-.5" />
<path d="M4.406 3.342A5.53 5.53 0 0 1 8 2c2.69 0 4.923 2 5.166 4.579C14.758 6.804 16 8.137 16 9.773 16 11.569 14.502 13 12.687 13H3.781C1.708 13 0 11.366 0 9.318c0-1.763 1.266-3.223 2.942-3.593.143-.863.698-1.723 1.464-2.383m.653.757c-.757.653-1.153 1.44-1.153 2.056v.448l-.445.049C2.064 6.805 1 7.952 1 9.318 1 10.785 2.23 12 3.781 12h8.906C13.98 12 15 10.988 15 9.773c0-1.216-1.02-2.228-2.313-2.228h-.5v-.5C12.188 4.825 10.328 3 8 3a4.53 4.53 0 0 0-2.941 1.1z" />
</svg>
Upload
</button>
</div>
<div>
<p style="margin:0px">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-person" viewBox="0 0 16 16">
<path d="M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6m2-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0m4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6 4m-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10s-3.516.68-4.168 1.332c-.678.678-.83 1.418-.832 1.664z" />
</svg>
@ViewBag.Name
</p>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container" style="text-align:center; font-size:.9rem">
©Copyright Reserved @DateTime.Now.Year | Contact Manager | <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.min.js"></script>
@RenderSection("Scripts", required: false)
</body>
</html>