Unable to implement a custom Identity from Csla.Security.CslaIdentity due to Serialization Error #1868
-
Hi, I'm having this error and I don't know what I'm missing or if this is actually an issue. I have a simple .Net MVC application executing a service using the HttpPortal. Please check my code below.. and let me know your thoughts. ` [Serializable] |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 19 replies
-
First, this is a poor strategy, because going forward ASP.NET Core and later require the use of Second, to create a custom identity type you should subclass But really, everyone's strategy needs to be to shift from custom principal/identity types to the standard |
Beta Was this translation helpful? Give feedback.
-
Thanks, Rocky. Regarding the Csla.Security.CslaIdentity class, I noticed everything works with the Binary Serializer, but not with the Mobile. Thanks again. |
Beta Was this translation helpful? Give feedback.
-
Ahh, in .NET Framework CSLA still defaults to using BinaryFormatter, and ClaimsPrincipal is not serializable. I put special behavior into MobileFormatter so it can serialize ClaimsPrincipal objects, but obviously I can't change the way Microsoft implements BinaryFormatter. If you configure CSLA to use MobileFormatter as its primary serializer, then it should work. |
Beta Was this translation helpful? Give feedback.
-
How can I change that?
|
Beta Was this translation helpful? Give feedback.
-
@ronnymgm it is now clear that this is a bug in the .NET Framework where the I see the following options for you:
|
Beta Was this translation helpful? Give feedback.
@ronnymgm it is now clear that this is a bug in the .NET Framework where the
ClaimsPrincipal
type doesn't properly deserialize itself based on the byte stream it creates.I see the following options for you:
MobileFormatter
can work around this issue - presumably by manually pulling the properties/data fromClaimsPrincipal
andClaimsIdentity
into a byte stream, and then putting the values into a new principal/identity pair