Last post Sep 10, 2013 11:40 PM by jats_ptl
Sep 10, 2013 05:39 AM|mmilan08|LINK
I have a problem serializing entities to ASP.NET ViewState because they are not marked as [Serializable]. What is the recommended approach to solve this problem ?
Sep 10, 2013 05:43 AM|anas|LINK
You can create partial class with same name and namespace as the related EF class that is generated and add the [Serializable] attribute to it.
I would like to mention that if you are using the EF model (EDMX) , the EF models might have a lot of information and additional attributes that are related to the EF itself, so serializing those entities might not be a good idea because the size of ViewState
will be large.
However, if you are using code frist, entities might be simpler. But anyway, try to store only what you need in the ViewState and avoid storing sensitive data as ViewState is not secure and will be rendered to the client's browser.
Sep 10, 2013 11:40 PM|jats_ptl|LINK
Please go through the links below:
Hope this helps.