private string Serialize(SessionStateItemCollection items) { MemoryStream ms = new MemoryStream(); BinaryWriter writer = new BinaryWriter(ms); List<string> itemsABorrar = new List<string>(); foreach (string item in items.Keys) { if (!(items[item].GetType().IsSerializable)) itemsABorrar.Add(item); } foreach(string item in itemsABorrar) items.Remove(item); if (items != null) { items.Serialize(writer); } writer.Close(); return Convert.ToBase64String(ms.ToArray()); }