会员提供商中的GetAllUsers在哪里?

时间:2021-06-27 11:27:55

I looked at membership provider documentation and there should be two GetAllUsers method in membership provider (http://msdn.microsoft.com/en-us/library/system.web.security.membership.getallusers ).

我查看了成员资格提供程序文档,并且在成员资格提供程序中应该有两个GetAllUsers方法(http://msdn.microsoft.com/en-us/library/system.web.security.membership.getallusers)。

But when I look at methods exposed by System.Web.Security (in

但是当我看到System.Web.Security公开的方法时(在

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.ApplicationServices.dll )

It only has one method (the one that has paging capability).

它只有一种方法(具有分页功能的方法)。

Where can I find a method to return all users from database? It seems there is no way to get list of all users or find how many user is in the database.

我在哪里可以找到从数据库返回所有用户的方法?似乎无法获取所有用户的列表或查找数据库中有多少用户。

--Update

--update

looking at System.Web.Security, i found that SqlMembershipProvider is defined as follow:

看着System.Web.Security,我发现SqlMembershipProvider定义如下:

public class SqlMembershipProvider : System.Web.Security.MembershipProvider

but this class doesn't have any public GetAllUsers() method.

但是这个类没有任何公共的GetAllUsers()方法。

How can I access its base GetAllUsers method?

如何访问其基本GetAllUsers方法?

3 个解决方案

#1


0  

I think you should be looking in the System.Web.dll not System.Web.ApplicationServices.dll

我认为你应该在System.Web.dll中查找System.Web.ApplicationServices.dll

#2


0  

The way it works is that you have to have your membership provider, like a SqlMembershipProvider, configured in your web.config. The Membership.GetAllUsers method will then take the default configured MembershipProvider and call its method GetAllUsers and pass in 0 for the current page index and int.MaxValue for the total records per page (as well as an out int to get the total records in the store).

它的工作方式是您必须在web.config中配置您的成员资格提供程序,如SqlMembershipProvider。然后,Membership.GetAllUsers方法将采用默认配置的MembershipProvider并调用其方法GetAllUsers并传入0表示当前页面索引,并传递int.MaxValue表示每页总记录数(以及输出int表示获取总记录数)商店)。

If you are having issues calling this method check the following:

如果您在调用此方法时遇到问题,请检查以下内容:

  • You have the correct .net assemblies referenced
    • System.Web
    • 的System.Web
    • System.Web.ApplicationServices
    • System.Web.ApplicationServices
    • System.Configuration
    • 系统配置
  • 您有正确的.net程序集引用System.Web System.Web.ApplicationServices System.Configuration
  • You have the correct namespace referenced System.Web.Security either
    • In your using statements at the top of the file
    • 在文件顶部的using语句中
    • Directly on the type where referenced
    • 直接在引用的类型上
  • 您有正确的命名空间引用System.Web.Security或者在文件顶部的using语句中直接在引用的类型上
  • Your web.config has a registered default MembershipProvider
  • 您的web.config有一个注册的默认MembershipProvider

Notes

  • SqlMembershipProvider, which derives from MembershipProvider, is not the same type or type hierarchy as type Membership. So not all the methods you see on Membership can be found on types deriving from MembershipProvider.
  • 源自MembershipProvider的SqlMembershipProvider与类型成员资格的类型或类型层次结构不同。因此,您在Membership上看到的所有方法都不能在从MembershipProvider派生的类型上找到。
  • The type Membership is static and so all its members including Membership.GetAllUsers are static as well.
  • 类型成员资格是静态的,因此其所有成员(包括Membership.GetAllUsers)也是静态的。
  • The type Membership is there as a convenience, most of its members call through to the registered default MembershipProvider.
  • 类型成员资格是为了方便,其大多数成员调用注册的默认MembershipProvider。

Code sample:

using System.Web.Security;
namespace MyNameSpace
{
    public class MembershipTests
    {
        public void Test()
        {
            var users = Membership.GetAllUsers();
            // same as
            var totalRecords = 0;
            users = Membership.GetAllUsers(0, int.MaxValue, out totalRecords);
            // same as (Membership.Provider gets the default registered MembershipProvider)
            users = Membership.Provider.GetAllUsers(0, int.MaxValue, out totalRecords);
        }
    }
}

From the documentation

从文档中

Remarks

GetAllUsers returns the information for all membership users for an application as a collection of MembershipUser objects. Be careful when using the GetAllUsers method with very large user databases, as the resulting MembershipUserCollection in your ASP.NET page may degrade the performance of your application.

GetAllUsers将应用程序的所有成员资格用户的信息作为MembershipUser对象的集合返回。将GetAllUsers方法与非常大的用户数据库一起使用时要小心,因为ASP.NET页面中生成的MembershipUserCollection可能会降低应用程序的性能。

#3


0  

The question is "Where is GetAllUsers in membership provider?"

问题是“会员提供商中的GetAllUsers在哪里?”

The answer is that it is not in MembershipProvider. It is in System.Web.Security.Membership

答案是它不在MembershipProvider中。它位于System.Web.Security.Membership中

The MSDN link you provided in your question says the same thing.

您在问题中提供的MSDN链接说明了同样的事情。

The method GetAllUsers static and overloaded.

方法GetAllUsers静态和重载。

int userCount = 0;
MembershipUserCollection muc1 =  System.Web.Security.Membership.GetAllUsers();
MembershipUserCollection muc2 = System.Web.Security.Membership.GetAllUsers(0, int.MaxValue, out userCount);

If you are having namespace issues, they shuffled some things around between .net 3.5 and .net 4.0

如果你遇到命名空间问题,他们会在.net 3.5和.net 4.0之间改变一些东西

This bit me several years ago.

几年前我就这么说。

.Net 4.0 System.Web.Security.MembershipProvider ambiguous reference?

.Net 4.0 System.Web.Security.MembershipProvider含糊不清的参考?

#1


0  

I think you should be looking in the System.Web.dll not System.Web.ApplicationServices.dll

我认为你应该在System.Web.dll中查找System.Web.ApplicationServices.dll

#2


0  

The way it works is that you have to have your membership provider, like a SqlMembershipProvider, configured in your web.config. The Membership.GetAllUsers method will then take the default configured MembershipProvider and call its method GetAllUsers and pass in 0 for the current page index and int.MaxValue for the total records per page (as well as an out int to get the total records in the store).

它的工作方式是您必须在web.config中配置您的成员资格提供程序,如SqlMembershipProvider。然后,Membership.GetAllUsers方法将采用默认配置的MembershipProvider并调用其方法GetAllUsers并传入0表示当前页面索引,并传递int.MaxValue表示每页总记录数(以及输出int表示获取总记录数)商店)。

If you are having issues calling this method check the following:

如果您在调用此方法时遇到问题,请检查以下内容:

  • You have the correct .net assemblies referenced
    • System.Web
    • 的System.Web
    • System.Web.ApplicationServices
    • System.Web.ApplicationServices
    • System.Configuration
    • 系统配置
  • 您有正确的.net程序集引用System.Web System.Web.ApplicationServices System.Configuration
  • You have the correct namespace referenced System.Web.Security either
    • In your using statements at the top of the file
    • 在文件顶部的using语句中
    • Directly on the type where referenced
    • 直接在引用的类型上
  • 您有正确的命名空间引用System.Web.Security或者在文件顶部的using语句中直接在引用的类型上
  • Your web.config has a registered default MembershipProvider
  • 您的web.config有一个注册的默认MembershipProvider

Notes

  • SqlMembershipProvider, which derives from MembershipProvider, is not the same type or type hierarchy as type Membership. So not all the methods you see on Membership can be found on types deriving from MembershipProvider.
  • 源自MembershipProvider的SqlMembershipProvider与类型成员资格的类型或类型层次结构不同。因此,您在Membership上看到的所有方法都不能在从MembershipProvider派生的类型上找到。
  • The type Membership is static and so all its members including Membership.GetAllUsers are static as well.
  • 类型成员资格是静态的,因此其所有成员(包括Membership.GetAllUsers)也是静态的。
  • The type Membership is there as a convenience, most of its members call through to the registered default MembershipProvider.
  • 类型成员资格是为了方便,其大多数成员调用注册的默认MembershipProvider。

Code sample:

using System.Web.Security;
namespace MyNameSpace
{
    public class MembershipTests
    {
        public void Test()
        {
            var users = Membership.GetAllUsers();
            // same as
            var totalRecords = 0;
            users = Membership.GetAllUsers(0, int.MaxValue, out totalRecords);
            // same as (Membership.Provider gets the default registered MembershipProvider)
            users = Membership.Provider.GetAllUsers(0, int.MaxValue, out totalRecords);
        }
    }
}

From the documentation

从文档中

Remarks

GetAllUsers returns the information for all membership users for an application as a collection of MembershipUser objects. Be careful when using the GetAllUsers method with very large user databases, as the resulting MembershipUserCollection in your ASP.NET page may degrade the performance of your application.

GetAllUsers将应用程序的所有成员资格用户的信息作为MembershipUser对象的集合返回。将GetAllUsers方法与非常大的用户数据库一起使用时要小心,因为ASP.NET页面中生成的MembershipUserCollection可能会降低应用程序的性能。

#3


0  

The question is "Where is GetAllUsers in membership provider?"

问题是“会员提供商中的GetAllUsers在哪里?”

The answer is that it is not in MembershipProvider. It is in System.Web.Security.Membership

答案是它不在MembershipProvider中。它位于System.Web.Security.Membership中

The MSDN link you provided in your question says the same thing.

您在问题中提供的MSDN链接说明了同样的事情。

The method GetAllUsers static and overloaded.

方法GetAllUsers静态和重载。

int userCount = 0;
MembershipUserCollection muc1 =  System.Web.Security.Membership.GetAllUsers();
MembershipUserCollection muc2 = System.Web.Security.Membership.GetAllUsers(0, int.MaxValue, out userCount);

If you are having namespace issues, they shuffled some things around between .net 3.5 and .net 4.0

如果你遇到命名空间问题,他们会在.net 3.5和.net 4.0之间改变一些东西

This bit me several years ago.

几年前我就这么说。

.Net 4.0 System.Web.Security.MembershipProvider ambiguous reference?

.Net 4.0 System.Web.Security.MembershipProvider含糊不清的参考?