Storing Interface type in ASP.NET Profile
- by NathanD
In my ASP.NET website all calls into the data layer return entities as interfaces and the website does not need to know what the concrete type is. This works fine, but I have run into a problem when trying to store one of those types into the user Profile. My interface implements ISerializable, like the following:
public interface IInsured : IPerson, IEntity, ISerializable
and the concrete type in the datalayer does implement ISerializable. My Profile property in web.config is:
<add name="ActiveInsured" type="FacadeInterfaces.IInsured" serializeAs="Binary" defaultValue="[null]"/>
It compiles just fine, but I get a runtime error on Profile.Save() saying that the interface cannot be serialized. I have also tried it with serializeAs="Xml". I thought that if my interface implemented ISerializable it would work.
Anybody had this problem before or know of a workaround?