1. In a ASP.NET application the session for the current user could expire after few or more minutes, based on the associated setting from
web.config
.
In order to fix this you should use the next setting from your
web.config
:
<sessionstate mode="InProc" cookieless="false" timeout="1440" />
2. If you want to preserve the user ID between postbacks, after the user login you should cache its value in the current
Session
like in the next example:
Session["UserID"]= userID;
Then during the postabcks, when you need the user ID, you could access it form the Session cache like in the code below:
int userID = (int)Session["UserID"];