I have a lot of pages in my project. In all pages I write:
if (!IsPostBack)
{
if (HttpContext.Current.Session["curUserRole"] == null)
{
DBUsers.SetUserStatusOnline("0", ViewState["curUserLogin"].ToString());
ViewState["curUserLogin"] = "";
Response.Redirect("~/Login.aspx");
}
else
{
ViewState["curUserLogin"] = HttpContext.Current.Session["curUserLogin"].ToString();
DBUsers.SetUserStatusOnline("1", ViewState["curUserLogin"].ToString());
}
}
When a user logs in on the site, the current user role is written into the session and the current user login is written in the viewstate. When the session finishes, I thought that I could view the current user login in the viewstate and set the offline status in the database. But when session
is null, the viewstate also null. What can I do?