Last post Dec 29, 2015 08:51 AM by Candice Zhou
Dec 26, 2015 08:57 PM|Arvind2015Asp.net|LINK
I am facing the below listed issue while trying to make use of the serializable object in C#. I have used the below code snippet
Session["YYY"] = dt;
The session variable was losing its value after the execution of the method in which the declaration was made. Hence had to go with the below listed config for setting the timeout to 940.
<sessionState mode="StateServer" cookieless="false" timeout="940" />
Received the below error after making the above change
Had marked the class as serializable as shown below
public class xyz
Dec 26, 2015 11:55 PM|PatriceSc|LINK
And which types are you using in your xyz class definition? More likely they are not all serializable.
Dec 27, 2015 08:52 PM|Arvind2015Asp.net|LINK
I am able to find the rootcause of my issue now I had added the web config entry with session that has caused the issue with the error message. I had added this because the value stored in my session variable loses its content when I actually hit the finally
block. So is there any option to deal with this because I would require the value again to be used in another method downstream.
Dec 27, 2015 09:06 PM|Arvind2015Asp.net|LINK
Also I have tried storing the value in Static variable but even that loses the value in the finally block.
Dec 27, 2015 10:02 PM|PatriceSc|LINK
Good point. It is always better to solve your actual problem rather than to just try something else without even understanding your initial issue.
Showing some code could help. Could it be that you are disposing the object you are trying to store in the session? Or could it be that the web app is restarting?
Dec 29, 2015 08:51 AM|Candice Zhou|LINK
It seems to be like session state is disabled in your web config on the webserver where you are deploying.
Check the difference in setting for session on your local machine and deployment server.