【发布时间】:2011-02-02 10:59:59
【问题描述】:
我有一个使用用户名凭据的 WCF 服务。现在 System.Web.Security.Membership.GetUser 总是返回 null 但它能够提取 aspnetdb 中的用户列表 (System.Web.Security.Membership.GetAllUsers())
但在服务端,“ServiceSecurityContext.Current.PrimaryIdentity.Name”始终返回正确的经过身份验证的用户名。
有人知道为什么 GetUser() 总是返回 null 吗?
这是来自 sql profiler 的跟踪
exec dbo.aspnet_Membership_GetUserByName @ApplicationName=N'myApplication',@UserName=N'',@UpdateLastActivity=1,@CurrentTimeUtc='2011-02-01 23:14:56.2830000'
注意上面的用户名是空白的。
【问题讨论】:
-
您确定有用户登录...
-
是.. 用户已通过身份验证.. 如果不是,“ServiceSecurityContext.Current.PrimaryIdentity.Name”将不会返回正确的用户名,不是吗?