私はasp.netにログインページを持っています..ログインに成功した場合、次のページにログイン時間が表示されます..次に、セッションタイムアウトを検出してlogin.aspxページにリダイレクトする一般的な関数を作成する方法は?それを呼び出すことができます他のすべてのページに
public partial class Login : System.Web.UI.Page
{
MainClass obj = new MainClass();
protected void bt_login_Click(object sender, EventArgs e)
{
    string s_name;
    SqlCommand cmd = new SqlCommand("select staff_id,staff_name from staff_details where staff_id='" + tb_loginid.Text + "' ", con);
    con.Open();
    SqlDataReader dr = cmd.ExecuteReader();
    if (dr.HasRows == true)
    {
        if (tb_password.Text == "ABCD" )
        {
            dr.Read();
            string id = dr[0].ToString();    
            s_name = dr[1].ToString();
            Session["staffname"] = s_name;
            Session["staffid"] = tb_loginid;
            String last_interaction_time = DateTime.Now.ToShortTimeString();
            Session["lasttime"] = last_interaction_time;
            Response.Redirect("Successfully_loggedin.aspx");
        }
    }
        else
        {  ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert('Incorrect LoginID or Password!')", true);
            lb_invalid.Visible = true;
            tb_password.Text = "";
        }
}
}
とlogged_inページは
public partial class Successfully_logined : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
 string name=(string)Session["staffname"];
 lb_welcome.Text = "Welcome " + name+"!";
 string last_login_time= (string)Session["lasttime"];
 lb_logintime.Text =last_login_time;
}
}
そしてweb.configは
<sessionState mode="InProc" cookieless="false" timeout="1">