This is not a duplicate of this question. I have to serialize the Property which is "ReadOnly". I can't do anything on this class, because this is System.Web.Security.MembershipUser
class, of course this is not sealed class.
[WebGet]
public string GetAllUsers()
{
List<MembershipUser> membershipList = new List<MembershipUser>();
MembershipUserCollection userCollection = Membership.GetAllUsers();
foreach (MembershipUser user in userCollection)
membershipList.Add(user);
string memberCollection = SerializeToString(membershipList, typeof(List<MembershipUser>));
List<MembershipUser> users = Deserialize(memberCollection, typeof(List<MembershipUser>)) as List<MembershipUser>;
return memberCollection;
}
Above code is what I used,
MembershipUserCollection userCollection = Membership.GetAllUsers();
GetAllUsers
method returns MembershipUserCollection
, but this does not have default accessor. So while serializing I get exception. That is the reason I went with List<MembershipUser>
. Here too I face trouble. This is eating my day, what could solve this?.
Edit: I'm using XmlSerializer.