SPContext.Current.Web.CurrentUser; return 错误的用户

SPContext.Current.Web.CurrentUser; return wrong user

当执行这条语句时 SPContext.Current.Web.CurrentUser 它给我用户 SharePoint\system 当我执行这条语句时

if (profileManager.UserExists(username))
                        { }

它说找不到用户。

我使用 SharePoint\spadmin 登录。为什么返回错误的用户名。

因为你的spadmin是系统用户

看看here: 或 here