I am placing user data in the session then passing it to viewdata to view on a page. Now when my user walks away from his computer for a while, the session ends and the data
I had that same problem with an old ASP.net app. The session expires but the user is still authenticated because session and authentication cookies are different and not necessarily they expire at the same time. What I did back then was use the global.asax Session_Start to check if the user was authenticated and log him out.
protected void Session_Start(Object sender, EventArgs e)
{
if (User.Identity.IsAuthenticated)
{
FormsAuthentication.SignOut();
Response.Redirect("~/SessionEnd.aspx");
}
}
This forces a user starting a session to login again. You may also use this event to recover session info from the database, or maybe redirecto him to another page but keep his credentials valid.