Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serialize ASP.NET Control collection

I've been tasked with converting an existing ASP.NET site from using InProc session management to using the ASP.NET State Server.

Of course what this means is that anything stored in the Session must be serializable.

One of the most complicated pages in the app is currently storing an ASP.NET control collection to the Session. This is failing miserably because the controls cannot be serialized automatically.

Short of totally rewriting how the page works to prevent the need for storing the control collection in the Session, does anyone have a trick/solution for making the collection serializable?

like image 651
Tim Cavanaugh Avatar asked Dec 30 '08 21:12

Tim Cavanaugh


People also ask

What is serialization in ASP net?

Serialization is the process of converting the state of an object into a form that can be persisted or transported. The complement of serialization is deserialization, which converts a stream into an object. Together, these processes allow data to be stored and transferred.

Are private fields serialized?

All fields, both public and private, are serialized and properties are ignored. This can be specified by setting MemberSerialization.

What does serialize mean in c#?

Serialization is the process of converting an object into a stream of bytes to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization.

What is serialization in ASP net core?

ASP.NET Core becomes the camelCase serialization as default. If we have migrated the application from Web API 2.0 to . NET core, the application may not be working. However, we can configure the serialization to PascalCase. Product.cs.


2 Answers

Rewrite the page. You'll thank yourself later. There are sure to be other problems if the original "programmer" (and I use that term loosely here) thought it was a good idea to store a control hierarchy in session.

like image 74
Robert C. Barth Avatar answered Oct 03 '22 00:10

Robert C. Barth


Don't store control collections in session state. Tess has a lot of articles about this, for example this one.

like image 20
erikkallen Avatar answered Oct 03 '22 00:10

erikkallen