This article will show you how you can redirect the user to the login page after user session is finish or timeout in your asp.net application using c#.net.
So for this article first we will create a new asp.net application and take a button control. Now on button click event add the below code. In this code we are invoking the session, which we will check the for timeout.
So for this article first we will create a new asp.net application and take a button control. Now on button click event add the below code. In this code we are invoking the session, which we will check the for timeout.
protected void
btnGenerate_Click(object sender, EventArgs e)
{
Session["SessionID"]="SessionUserId";
}
|
Now on page load or on master page page load we will add the below code.
protected void Page_Load(object sender, EventArgs e)
{
if (Session["SessionID"] == null)
{
Response.Redirect("login.aspx");
}
}
|
In above code i have check the session value is null or not. If it's null then user will be redirected to the login page.
0 comments:
Please let me know your view