使用 ASP.net 成员资格在 silverlight 中获取 aspnet_Users
希望有人可以帮忙。
在网上环顾四周,但似乎无法解决(或理解)这个问题。
上的代码
我已经尝试过发布在http://blogs.msdn.com/b/kylemc/archive/2010/05/10/using-asp-net-membership-in-silverlight.aspx (这里不会重复 MembershipServiceUser 类,因为它很长,可以在提到的页面上看到)
我已经使用该类和返回用户的代码设置了域服务:
//[RequiresRole("Managers")]
public IEnumerable<MembershipServiceUser> GetAllUsers()
{
return Membership.GetAllUsers().Cast<MembershipUser>().Select(u => new MembershipServiceUser(u));
}
我取出了 RequiresRole 进行测试。
我似乎有点金发碧眼的是 GetAllUsers() 方法的调用。
在我后面的代码中,我使用:
MembershipDataContext context = new MembershipDataContext();
EntityQuery<MembershipServiceUser> users = context.GetAllUsersQuery();
我不能 100% 确定这是否是使用该方法的正确方法,或者是否有其他问题,因为
context.GetAllUsersQuery(); returns "Enumeration yielded no results"
kylmc 使用的代码中也有一个问题 //RequiresRole("Admin")]。这是在 ASP.NET 配置编辑器中创建的自定义角色吗?
查看有关在 Silverlight 中使用 ASP.NET 身份验证服务的另一个教程,我创建了一个名为“Managers”的角色,并将登录用户添加到该角色。 使用具有角色管理员的用户登录没有帮助,并且仍然不会产生结果。
我可以看看有什么想法吗?
非常感谢
尼尔
Hope somebody can help.
Have looked around on the net but cannot seem to solve (or understand) this.
I have tried the code posted at
http://blogs.msdn.com/b/kylemc/archive/2010/05/10/using-asp-net-membership-in-silverlight.aspx
(not going to repeat the class MembershipServiceUser here as it is quite long and can be seen on the mentioned page)
I have set up the domain service with the class and the code to return the users:
//[RequiresRole("Managers")]
public IEnumerable<MembershipServiceUser> GetAllUsers()
{
return Membership.GetAllUsers().Cast<MembershipUser>().Select(u => new MembershipServiceUser(u));
}
I took out the RequiresRole for testing.
What I seem to be a bit blonde about is the calling of the GetAllUsers() method.
In my code behind I am using:
MembershipDataContext context = new MembershipDataContext();
EntityQuery<MembershipServiceUser> users = context.GetAllUsersQuery();
I am not 100% sure if this is the correct way to use the method or if something else is wrong because
context.GetAllUsersQuery(); returns "Enumeration yielded no results"
One question is also in the code kylmc uses //RequiresRole("Admin")]. Is this a custom role created in the ASP.NET Configuration editor?
Looking at another tutorial regarding using the ASP.NET authentication service in Silverlight, I create a role called "Managers" and added the login user to that role.
Logging in using a user with role Managers doesn't help and results are still not yielded.
Any ideas I could possible look at?
Many thanks
Neill
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查询涉及两个步骤。
例子:
There are two steps involved with querying.
Example: