Jeremy Boyd
Jeremy Boyd

Reputation: 5405

Search ASP.Net Profiles

I am looking for a way to search through every users profile using the standard ASP.Net Profile Provider. Is this possible, or should I create a new Profile Provider?

Here is the scenario:

I would like to use this all through the membership/profile providers without having to code against the database directly.

Upvotes: 0

Views: 986

Answers (2)

Rob Windsor
Rob Windsor

Reputation: 6859

The functionality you want is included in the Profile API.

You can get an individual users profile using:

HttpProfile profile = Profile.GetProfile("Fred");

You can get all the profiles using:

var allUsers = Membership.GetAllUsers();
foreach (MembershipUser user in allUsers)
{
    var prof = ProfileBase.Create(user.UserName, true);
}

Upvotes: 1

nshaw
nshaw

Reputation: 2625

I believe the standard provider will only work for the current user. You would need a custom profile provider to retrieve the information for other users. Fortunately it is really easy to do. That link has an example of a custom provider that allows you to retrieve the profiles of other users. If you use his example, be sure to note the person's comment about removing the profile section from your web.config. I had to do that to make mine work correctly.

Upvotes: 0

Related Questions