How to log off multiple MembershipUsers that are not the current user?

Posted by Sgraffite on Stack Overflow See other posts from Stack Overflow or by Sgraffite
Published on 2011-01-05T01:33:22Z Indexed on 2011/01/05 1:54 UTC
Read the original article Hit count: 466

I'm using the MembershipProvider that is part of the MVC2 default project.

I'd like to be able to take a list of user names, and log the users off, and destroy their session if needed. The closest I can seem to come is this:

foreach(string userName in UserNames)
{
    MembershipProvider MembershipProvider = new MembershipProvider();
    MembershipUser membershipUser = MembershipProvider.GetUser(userName, true);
    Session.Abandon();
    FormsAuthentication.SignOut();
}

I think I need to use a session and/or signout method related the user I want to log out, but I am unsure where those would be.

What is the proper way to do this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc-2