connectseekers.com

Thursday, 13 October 2016

Redirection User To Login Page After Session Time Out In Asp.Net Using C#

10/13/2016 - By Pranav Singh 0

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.

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.

About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com
Email Id : contact@aspdotnet-pools.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Top jQuery Plugins

Global Classified : Connectseekers.com
© 2014
back to top