views:

47

answers:

1

Hello,

I'm having a problem of losing session variable on my website. It append at random times so there is no particular behavior that cause this. What can be the cause of this session lost?

I've read everywhere on this site that I could put my session in "sql server" mode so everything is written on the server, can it be a solution?

My server is on 1and1 shared hosting, can it be their fault?

Thanks !

DarkJaff

+2  A: 

Check with the hosting provider that your application is not being hosted on a load balanced server. If the server is being load balanced, your users will lose their session state information when the load balancer sends their request to another server. There are 3 settings Session State mode property: InProc - Will store state information locally on the server from which the request is made (only effective when the application is being hosted on a single server in a non-load balanced environment) StateServer - Allows a specially configured server to host state information for an entire web farm (I believe StateServer began to be offered on .NET Framework v2.0). SqlServer - Allows a specially configured SQL Server instance to store session information for a web farm [This information will vary slighty in a web garden scenario.]

See MSDN for more information on Session State.

This can happen very randomly based on their load balancing settings (think: sticky load balancing) and can work for several minutes one time and fail almost immediately another time.

The other possibility is the timeout property of the sessionstate setting in the web.config has been set to a low value (it is in minutes) and the session is expiring.

ben f.
For the timeout property, this is ok. The session is set to 1 hour so it's not the problem. But the load balancing is really interesting. I will look forward with my company to see if they do that. But I'm looking to make my session in sqlserver. I'll keep this thread updated and mark you answer as "accepted" as soon as my problem go away :)
DarkJaff
You were right... They use load balancing so each time the server change, I loose the session. But now I'm searching for a way to use session. I will write a new question! Thanks a lot!
DarkJaff