如何在MVC环境中的MasterPage顶部显示欢迎"CurrentUserName"?

1 c# asp.net-mvc partial-views

有人告诉我,我可以在任何Controller中创建ActionResult并使用User.Identity.Name返回PartialView.然后我可以在我的MasterPage中使用RenderPartialView来显示用户的名字.我试图实现它,但不断收到错误,系统没有看到我的PartialView.请有人请详细解释如何实施?非常感谢你

不幸的是,这个项目的结构方式,Logon没有在Master中呈现.它从WebConfig调用并在AccountController中进行身份验证.

<authentication mode="Forms"> 
      <forms loginUrl="~/Account" timeout="2880"/> 
</authentication>
Run Code Online (Sandbox Code Playgroud)

Jai*_*ime 6

您已经在创建新MVC项目时为您弹出的基本模板中有一个工作示例...在site.master中,您有一个Html.RenderPartial("LogOnUserControl"),它呈现LogOnUserControl局部视图(位于视图/共享文件夹)...如果用户通过身份验证,该控件将显示User.Identity.Name ...

除非这不是你的意思,在这种情况下,我认为我们需要对你的问题进行更多的解释:)