System.Web.UI.WebControls + SqlServer Session State
I'm working on an application where a fair amount of data is being stored in the page's viewstate. As the project has progressed, the performance of the page really started to degrade. So, to correct the project, we started storing the page's viewstate in a session object on the server.
Unfortunately, when we started doing this we started getting the following error:
Unable to serialize the session state. Please note that non-serializable objects or MarshalByRef objects are not permitted when session state mode is 'StateServer' or 'SQLServer'.
After looking at (and for) the error we are stumped! It seems that there is a web control that just won't serialize. However, if I'm reading the details of the error then it's one of Microsoft's own!
Any help to solve this problem is greatly appreciated!
The details of this error
[SerializationException: The type System.Web.UI.WebControls.WebControl in Assembly System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a is not marked as serializable.]
System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type, Boolean excludeNonSerializable) +965
System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) +300
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter) +493
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter) +48
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header inHeaders, __BinaryWriter serWriter, Boolean fCheck) +683
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header headers, Boolean fCheck) +136
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph) +13
System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer)
Do you know which control on your page is the WebControl that wouldnt serialize
and Are you using any custom server controls which derive from the WebControl class ?
I hope you guys do realise your server load is going to be high with the viewstate information in your session.. You could have considered caching selectively Anyway let me know
Another thought on this case,
we use View state normally to avoid going back to the database and handling event data across postbacks and other reasons,
Now when use session to store viewstate information I was kind of ok with it,
but then when you said you are using SQL Server Session State management to manage viewstate , you are basically going back to the database
In which case you might as well query your actual database and get more reliable up to data data? than sending viewstate to session in a SQL Server state implementation
I am not sure in the first place if you are using SQL Server State management or ASp.Net State Service, but seems like your web.config is set to one of these , if you didnt intend to use one of these I guess your session setting should say InProc ?
We're still trying to track down the errant control (or controls). But, save tearing apart the form and then putting it back together (one piece at a time), I'm not sure how we are going to find it.
Are you using SQL Server session state management? or asp.net state service to do this job? or InProc session i can infer what the error says but is it that you guys intend to use?
Last Post: 01-19-2002, 03:09 PM
By KraKheD in forum ASP.NET
Last Post: 01-17-2002, 07:28 PM
By Ariel in forum ASP.NET
Last Post: 08-12-2000, 01:47 PM
By Ariel Azia in forum ASP.NET
Last Post: 08-02-2000, 02:10 AM
By Ariel in forum ASP.NET
Last Post: 08-01-2000, 01:34 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center