【发布时间】:2016-01-13 05:04:45
【问题描述】:
我有以下布局页面:
<body>
<nav>@Component.Invoke("Navigation")</nav>
<main>@RenderBody()</main>
</body>
ViewComponent 为经过身份验证和未经过身份验证的用户呈现两种不同的视图:
public class NavigationViewComponent : ViewComponent
{
public IViewComponentResult Invoke()
{
if(User.Identity.IsAuthenticated)
{
return View("User");
}
return View("Guest");
}
}
我还有一个注销用户的操作方法:
public class HomeController : Controller
...
public async Task<IActionResult> LogOut()
{
await _signInManager.SignOutAsync();
return View("Index");
}
}
我想渲染ViewComponent 在LogOut动作方法被调用后,怎么做?
【问题讨论】:
标签: c# asp.net-core asp.net-core-identity asp.net-core-viewcomponent