In my asp.net application if network disconnected again connecting means session objectes cleared.i want if network disconnected again connecting means need to maintain session data.cokkies i can't use ..plz advice how to maintain session even if network
disconnected stage also.
first please try with incresing session timeout in config , if not work then go with below solution
To work around this problem, you can use StateServer or SqlServer session state mode. ASP.NET provides these other approaches for storing session state data. In the StateServer and SqlServer modes, your session state is not stored in the AppDomain
of the Web application.
OutProc Session State
In OutProc Session ,Sessin State is stored In the StateServer and SqlServer modes, your session state is not stored in the AppDomain of the Web application.
1.StateServer: Alternately, StateServer mode uses a stand-alone Microsoft Windows service to store session variables. Because this service is independent of Microsoft Internet Information Server (IIS), it can run on a separate
server. You can use this mode for a load-balancing solution because multiple Web servers can share session variables. Although session variables are not lost if you restart IIS, performance is impacted when you cross process boundaries. 2.SqlServer: If you are greatly concerned about the persistence of session information, you can use SqlServer mode to leverage Microsoft SQL Server to ensure the highest level of reliability. SqlServer mode is similar to out-of-process mode,
except that the session data is maintained in a SQL Server. SqlServer mode also enables you to utilize a state store that is located out of the IIS process and that can be located on the local computer or a remote server.
sameer.khanjit@gmail.com
View Blog Click "Mark as Answer" on the post that helped you.
Marked as answer by Angie xu - MSFT on Dec 25, 2012 05:33 AM
Network disconnection has nothing to do with session expiry. Session will expire as already said, if there is some period of inactivity .. default is 20 min which you can change. But in a webhosting environment there are many more concerns that can cause
session failure.. that may include..
1.) browser history removed (that means session identification cookie lost and server considered next request as new)
2.) the application pool recycled (due to memory over use, or crash of application)
3.) website recompiled (web.config changed or a new dll uploaded, or code in App_Code changed)
4.) server restart
In a shared hosting enivronment, problems can be even severe.. because normally more than one applications are hosted under one application pool. So sessions behave unexpectedly.
To ensure your session lasts the required time, you should try to use a session storage mechanism that is 'out process' that include 'state serevr' or 'sqlserver'.
This article explains how to store sessions in sql server.
Please refer the link below, it will give a full knowledge about session to you, the concept, session mode, advantages of session, session and cookie and so on. I think it’s helpful for you to understand your problem better.
As many have mentioned already, there are two main ways you can store your ASP.NET sessions.
InProc
OutProc
You must be saving the variables in InProc.You should save the sessions state OutProc in order to keep the information even if network is disconnected.Now ,There are three options available to you if you want to save your sessions in OutProc.
SQL Server
StateServer
Distributed Cache provider
Someone has already explained the first two.I will explain the last alonf with its benefits and disadvantages of other two.See, when you start saving your sessions in Sql Server, there comes a time when you either start running out of space or your application
performance starts degrading since there are too many simultaneous reads and writes since you would be saving temporary data like sessions in it as well as permanenet data about users.
State server gives you performance boost since its dedicated t storing sessions only and its optimized for it.But there are two main problems that come with it.
Its not scalabale.So when you have multiple ASP.NEt applications storing sessions and too many simultaneous users, you cannot add another server to cater more application load.
Ther is an issue called "Single Point of Failure".This means that if your server goes down,all of the applications sessions data will be lost since its only one server where all of your applications are storing the data.
Now, Distributed cache.
It is fast since its in-memory as opposed to StateServer and SQL Server.
Its scalable since you can always add more cache servers to cater more applications and users.
Its reliable since its a distributed cache.So if one cache server goes down, at max you will lose a part of the data and other aplications will remain functioning properly.
There are many third-party distributed cache providers which can be plugged with your ASP.NEt applications without the need of any code change.
inbaa
Member
341 Points
304 Posts
asp.net c# Session
Dec 17, 2012 01:49 PM|LINK
Dear Friends,
In my asp.net application if network disconnected again connecting means session objectes cleared.i want if network disconnected again connecting means need to maintain session data.cokkies i can't use ..plz advice how to maintain session even if network disconnected stage also.
aptbid2002
Member
244 Points
52 Posts
Re: asp.net c# Session
Dec 17, 2012 01:56 PM|LINK
Session state usually expires after 20 mins. If you are disconnected longer than that you will need to use database session or cookies.
sameer_khanj...
Star
7504 Points
1466 Posts
Re: asp.net c# Session
Dec 18, 2012 04:50 AM|LINK
first please try with incresing session timeout in config , if not work then go with below solution
To work around this problem, you can use StateServer or SqlServer session state mode. ASP.NET provides these other approaches for storing session state data. In the StateServer and SqlServer modes, your session state is not stored in the AppDomain of the Web application.
OutProc Session State
In OutProc Session ,Sessin State is stored In the StateServer and SqlServer modes, your session state is not stored in the AppDomain of the Web application.
1.StateServer: Alternately, StateServer mode uses a stand-alone Microsoft Windows service to store session variables. Because this service is independent of Microsoft Internet Information Server (IIS), it can run on a separate server. You can use this mode for a load-balancing solution because multiple Web servers can share session variables. Although session variables are not lost if you restart IIS, performance is impacted when you cross process boundaries.
2.SqlServer: If you are greatly concerned about the persistence of session information, you can use SqlServer mode to leverage Microsoft SQL Server to ensure the highest level of reliability. SqlServer mode is similar to out-of-process mode, except that the session data is maintained in a SQL Server. SqlServer mode also enables you to utilize a state store that is located out of the IIS process and that can be located on the local computer or a remote server.
sameer.khanjit@gmail.com
View Blog
Click "Mark as Answer" on the post that helped you.
deepthoughts
Contributor
7288 Points
1051 Posts
Re: asp.net c# Session
Dec 18, 2012 08:03 AM|LINK
Network disconnection has nothing to do with session expiry. Session will expire as already said, if there is some period of inactivity .. default is 20 min which you can change. But in a webhosting environment there are many more concerns that can cause session failure.. that may include..
1.) browser history removed (that means session identification cookie lost and server considered next request as new)
2.) the application pool recycled (due to memory over use, or crash of application)
3.) website recompiled (web.config changed or a new dll uploaded, or code in App_Code changed)
4.) server restart
In a shared hosting enivronment, problems can be even severe.. because normally more than one applications are hosted under one application pool. So sessions behave unexpectedly.
To ensure your session lasts the required time, you should try to use a session storage mechanism that is 'out process' that include 'state serevr' or 'sqlserver'.
This article explains how to store sessions in sql server.
http://support.microsoft.com/kb/317604
Thanks.
Jayadeep Bob...
Member
7 Points
19 Posts
Re: asp.net c# Session
Dec 18, 2012 09:14 AM|LINK
Try uSing Cache like cache["abc"]
Angie xu - M...
All-Star
20240 Points
1717 Posts
Microsoft
Re: asp.net c# Session
Dec 19, 2012 09:05 AM|LINK
Hi
So many great posts here.
Please refer the link below, it will give a full knowledge about session to you, the concept, session mode, advantages of session, session and cookie and so on. I think it’s helpful for you to understand your problem better.
http://www.codeproject.com/Articles/32545/Exploring-Session-in-ASP-Net#11
Hope it helps you,
Kind regards
Feedback to us
Develop and promote your apps in Windows Store
kevinryan
Member
14 Points
1 Post
Re: asp.net c# Session
Dec 21, 2012 10:56 AM|LINK
As many have mentioned already, there are two main ways you can store your ASP.NET sessions.
You must be saving the variables in InProc.You should save the sessions state OutProc in order to keep the information even if network is disconnected.Now ,There are three options available to you if you want to save your sessions in OutProc.
Someone has already explained the first two.I will explain the last alonf with its benefits and disadvantages of other two.See, when you start saving your sessions in Sql Server, there comes a time when you either start running out of space or your application performance starts degrading since there are too many simultaneous reads and writes since you would be saving temporary data like sessions in it as well as permanenet data about users.
State server gives you performance boost since its dedicated t storing sessions only and its optimized for it.But there are two main problems that come with it.
Now, Distributed cache.
There are many third-party distributed cache providers which can be plugged with your ASP.NEt applications without the need of any code change.
Kevin Ryan
Alachisoft
www.alachisoft.com
Shailendra S...
Member
551 Points
145 Posts
Re: asp.net c# Session
Dec 24, 2012 02:26 PM|LINK
In this case you can keep outporc Session state e.g .Sql server or State server ..
www.techaray.com