MVC 4 User.Identity.Name与WebSecurity.CurrentUserName之间的区别

时间:2013-02-03 18:26:26

标签: asp.net-mvc

在ASP.NET MVC 4中,User.Identity.NameWebSecurity.CurrentUserName之间有什么区别?我可以互换使用吗?

1 个答案:

答案 0 :(得分:5)

礼貌反思:

public static class WebSecurity
{
    ...

    public static string CurrentUserName
    {
        get
        {
            return Context.User.Identity.Name;
        }
    }

    ...
}     

让我们回答你的问题:

  

User.Identity.NameWebSecurity.CurrentUserName之间有什么区别?

无。

  

我可以互换使用吗?