使用 ASP.net 成员资格在 silverlight 中获取 aspnet_Users

发布于 2025-01-07 19:04:38 字数 1268 浏览 0 评论 0原文

希望有人可以帮忙。

在网上环顾四周,但似乎无法解决(或理解)这个问题。

上的代码

我已经尝试过发布在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静待花开 2025-01-14 19:04:38

查询涉及两个步骤。

  1. 从域服务上下文获取查询对象(同步)。
  2. 从域服务上下文加载查询(异步)。

例子:

public void Load()
{
  // define the query
  var query = context.GetAllUsersQuery();

  // start running the query, and when the results return call
  // OnGetAllUsersLoaded
  context.Load(query, OnGetAllUsersLoaded, null);
}

public void OnGetAllUsersLoaded(LoadOperation op)
{
  var results = op.Entities;
}

There are two steps involved with querying.

  1. Get a query object from the Domain Service context (synchronous).
  2. Load the query from the Domain Service context (asynchronous).

Example:

public void Load()
{
  // define the query
  var query = context.GetAllUsersQuery();

  // start running the query, and when the results return call
  // OnGetAllUsersLoaded
  context.Load(query, OnGetAllUsersLoaded, null);
}

public void OnGetAllUsersLoaded(LoadOperation op)
{
  var results = op.Entities;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文