On every page load just check the value of the Session, if this is null then simply just return to the login page.
protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserID"] == null)
Response.Redirect("loginPage.aspx");
}
but better approach is create another page e.g. BasePage and inherit it with "System.Web.UI.Page" and each .aspx.cs should inherit with this BasePage.
Now u can right this logic only once in the BasePage.
public class basePage : System.Web.UI.Page
{
protected override void OnLoad(EventArgs e)
{
if (Session["UserID"] == null)
Response.Redirect("loginPage.aspx");
base.OnLoad(e);
}
}
public partial class _Default : basePage