我的一些自定义 ASP.NET MVC 助手有单独的项目
在我的一个助手中,我需要检查用户身份。
我怎样才能得到 User.Identity
在那里工作?
默认情况下,它位于 System.Security.Principal
在名为 interface IPrincipal
的界面中
最佳答案
您可以通过以下方式更轻松地访问它:
HttpContext.Current.User.Identity
所以 HttpContext.Current 是诀窍。
关于asp.net-mvc-3 - 如何让 User.Identity 在 Controller 外工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5898170/