I am trying to use LINQ on the .NET Membership.GetAllUsers() collection, for example when getting all usernames:
var usernames = Membership.GetAllUsers().Cast<MembershipUser>().Select(x=>x.UserName).ToList();
But VS tells me that it is not supported..
Membership is a part of Web.Security, same as MembershipUser
Here is my connection string (if that is of any relevance):
<add name="ApplicationServices" connectionString="Data Source=somerserver.xx\SQLEXPRESS;Initial Catalog=bedriftsmelding;User Id=SomeUser;Password=SomePassword;Integrated Security=False" providerName="System.Data.SqlClient" />
Stack trace:
System.NotSupportedException was unhandled by user code
Message=Specified method is not supported.
Source=System.Web.Extensions StackTrace:
at System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider.GetAllUsers(Int32
pageIndex, Int32 pageSize, Int32& totalRecords)
at System.Web.Security.Membership.GetAllUsers(Int32 pageIndex, Int32 pageSize, Int32& totalRecords)
at System.Web.Security.Membership.GetAllUsers()
at Bedriftsmelding.Nettside.Models.CompanyUsers.GetUserIdFromUserName(String
username) in
C:\Projects\Bedriftsmelding\Bedriftsmelding.Nettside\Models\CompanyUsers.cs:line
26
at Bedriftsmelding.Tests.DTO.CompanyUsersTest.TestGetUserIdFromUserName()
in
C:\Projects\Bedriftsmelding\Bedriftsmelding.Tests\DTO\CompanyUsersTest.cs:line
16 InnerException:
Looks like you’re using a ClientFormsAuthenticationMembershipProvider rather than the default SqlMembershipProvider.
According to the docs for ClientFormsAuthenticationMembershipProvider, GetllAllUsers is not supported and throws a not supported exception.
http://msdn.microsoft.com/en-us/library/system.web.clientservices.providers.clientformsauthenticationmembershipprovider.getallusers.aspx
It appears that only the basic ValiateUser and a few other functions work with this provider, as it’s designed for use with the Ajax extensions. None of the user functions work, such as GetUser, GetAllUsers, DeleteUser, CreateUser, etc…