I have been following an article on how to implement a custom Basic authentication with .net.
This is the article
The code uses an interface - IBasicUser - that derives from IIdentity. The class BasicUser implements IBasicUser. An instance of BasicUser is created and from that a GenericPrincipal is constructed.
IBasicUser bu = new BasicUser();
context.Context.User = new GenericPrincipal(bu, new string[] { });
When I run the code I get an exception.
Type 'Smithfamily.Blog.Samples.BasicUser' in assembly 'LM_TESTS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
So I had a look at the System.Security.Principal.GenericIdentity class in Reflector and found that it is indeed marked with the attributes [Serializable. ComVisible(true)]
The Documentation on IIdentity doesn't say anything about implementations needing to be serializable. From the exception and Reflector I assume however that it does. So I add the [Serializable] attribute to the BasicUser class.
Now I get a new exception when I run the code.
[SerializationException: Type is not resolved for member 'Smithfamily.Blog.Samples.BasicUser,LM_TESTS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.]
I am not very familiar with Serialization and don't really understand what is going on or what the problem is. Please could you help enlighten me. Thanks.