Click here to Skip to main content
15,909,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to encrypt and decrypt the connectionstring in web.config .it is working fine.
i had used DataProtectionConfigurationProvider:method.

my problem is if i encrypt then it will dynamically change my web.config file.but my session is becoming null .WHY

session in mypage is coming but the same session object cant be available in another page i.e if we use reponse.redirect(defalut2.aspx) it is not coming in default2 page


Thanks
Srinivas
Posted
Comments
srinvas 9-Jul-12 19:18pm    
Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.
getting this error while i switched from inproc to state server what to do?
how can i know where the error is from ?

i had placed [serializable]attribute in DAL file still getting same error?

1 solution

If you change web.config IIS reloads the file and the app pool it is in which resets the Session. You need to use either the ASP.Net Session State or put your Session into SQL. It is easy to do. See here.[^]
 
Share this answer
 
Comments
srinvas 6-Jul-12 14:48pm    
thanks for your answer but i want to use session only in inproc and is there a way that web.config should change and IIS dont restart.actually the website is already in production we dont have encryption in our site.so now if we want to use state server it will be problem for us. so please give any suggestions
ZurdoDev 6-Jul-12 14:52pm    
No. That is the way IIS works. However, changing to ASP.Net State Service or to db is very, very simple. If you install the ASP.Net State Service then all you have to do is make a change in web.config. None of your code needs to change.
srinvas 6-Jul-12 15:12pm    
so i had done in local system like this
1. Go to Control Panel > Administrative Tools > Services
2. Select Asp.Net State Service.
3. Right Click on Asp.net State Service and choose start from popup menu.

and in web.config add
<sessionstate mode="StateServer" stateconnectionstring="tcpip=127.0.0.1:42424" cookieless="false" timeout="120">
i local system it is working fine and what about production.
so in production i had to do the same right what about the stateConnectionString="tcpip=127.0.0.1:42424" is it same or i had to change in production server.
srinvas 6-Jul-12 15:27pm    
and i have to use [Serializable] attribute for every session item
i think it will be a long process, in present production code i have to change all files that have this objects.
ZurdoDev 6-Jul-12 15:35pm    
You shouldn't have to use [Serializable] attribute for everything, unless you are storing custom objects in the session.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900