如何获得当前用户在Asp.Net MVC [英] How to get current user in Asp.Net MVC
本文介绍了如何获得当前用户在Asp.Net MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在表格模型中,我用来获取当前登录的用户通过
In forms model, I used to get current logged in user by
Page.CurrentUser
我要如何在ASP.NET MVC控制器类中当前用户?
How do I get current user inside a controller class in ASP.NET MVC?
推荐答案
如果您需要在控制器内获得用户,使用用户
控制器的性能。如果您认为需要的话,我会填充你特别需要在的ViewData code>,或者你可以只调用用户,因为我认为这是一个属性
的ViewPage
。
If you need to get the user from within the controller, use the User
property of Controller. If you need it from the view, I would populate what you specifically need in the ViewData
, or you could just call User as I think it's a property of ViewPage
.
这篇关于如何获得当前用户在Asp.Net MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文