0
votes

I am very new to asp.net (mvc) and I am trying to build a sample admin mvc4 app where I can get a list of users with the new membership schema.

I am very confused with the new membership, it seems that if I want to use the out-of-the-box SimpleMembershipProvider I can't use methods built-in with the old asp.net membership and I have to implement all the methods by myself, especially if I want to use EF (is that right?)

Here is a sample code (working with the old provider) of what I am trying to achieve with the new provider

controller

public class MemberController : Controller
{
    public ActionResult Index()
    {
        var users = Membership.GetAllUsers();
        return View(users);
    }

}

view

<ul>
    @foreach (var item in Model)
    {
        <li>@Html.DisplayFor(model => model[item.ToString()].UserName)</li>
    }
</ul>

I would be very pleased if someone could provide me the steps, guideline, or source in order to implement this, the right way (did I have to create my own custom membership provider?). I know it's something really basic but It could help me to understand. Thank you

1

1 Answers

1
votes

SimpleMembership is, as it says, a simpler form of Membership, and as such it doesn't implement many of the methods in the base MembershipProvider class. GetAllUsers is one of those that it does not implement.

But, it's relatively simple to just query the Users table and get the list of users. And it's more efficient.

This doesn't mean you can't use any of the methods in the Membership class, but some are not implemented. It's the price you pay for a simpler membership model.

You can always go back to the old membership. Just disable the SimpleMembership initialization and SimpleMembership will pass through to the old SqlMembership provider.