有人告诉我,我可以在任何 Controller 中创建 ActionResult 并返回带有 User.Identity.Name 的 PartialView。然后我可以在我的 MasterPage 中 RenderPartialView 以显示用户名。我试图实现它,但不断收到系统没有看到我的 PartialView 的错误。有人可以请详细解释如何实施吗?非常感谢
不幸的是,这个项目的结构方式,Logon 不是从 Master 中呈现的。它从 WebConfig 调用并在 AccountController 中进行身份验证。
<authentication mode="Forms">
<forms loginUrl="~/Account" timeout="2880"/>
</authentication>