0

次のレイアウト ページがあります。

<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が、どうすればいいですか?

4

1 に答える 1