Disappointment
After struggling for 3 days with the Membership API's for ASP.Net I GIVE UP! I'm fed up with the MORT-Approach that MS seems to take in ASP.Net.
How would you count the number of users of an application?
Membership.GetNumberOfUsers(); //I know that this doesn't exist, but bare with me!
Right? Wrong! MS seems to believe that the right way is this one:
MembershipUserCollection muc = Membership.GetAllUsers(pageIndex, pageSize, out totalRecords);
Oh, cool so I get the totalRecords out, even though I just loaded all data from all users? WRONG! This only returns to you the number of items that was loaded, which again seems kinda dumb since you could easily count the number of items loaded by using muc.Count!!!!!!!
How do I know this? If I use the other overload for GetAllUsers (the one with no parameters) it returns 3 users. Now if I pass pageIndex of 0 and pageSize of 2, I get 2 records and totalRecords equals 2! It should be 3 right!?!??! So I can effectively use server side paging.
This is one of the issues with the VERY broken Membership of ASP.Net. It doesn't support SSO out-of-the-box (even though the OSS community is giving back to MS again!), it's hard to create a new user (something that in my opinion should be ridiculously simple, and TOP of the ICE-CREAM: MembershipUser IS NOT SERIALIZABLE! This is where someone will say: "Oh yes it is!" Just try doing it!!! The username property is read-only which means it doesn't get SERIALIZED!
Again MS proves that they can't listen to what the community is doing, because I WON'T believe that any decent developer would bestow such an incomplete thing on his team. Oh sure, the ASP.Net components that integrate with MembershipProvider and RoleProvider are very nice. But, unless you are building a Hello-World application, they won't do the job. Needless to say that if I can't find another solution quick I'll just do what real developers do: create one that uses proven design guidelines.
I'm a big MS fan as it is clear in my blog title, so I HATE to write such posts, since MS keeps proving over and over that they don't aim at writing extensible solutions. They are aiming at writing solutions that'll cater for the majority of their customers. Why care for quality, design principles and extensibility, when you can just cash in another version of ASP.Net?
*sigh*...days without sleep ahead...

#107