次のレイアウト ページがあります。
<body>
<nav>@Component.Invoke("Navigation")</nav>
<main>@RenderBody()</main>
</body>
ViewComponent
認証されたユーザーと認証されていないユーザーの 2 つの異なるビューをレンダリングします。
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
が、どうすればいいですか?