Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have to show the message alert box when session expires.
I tried like this in my Master page,
C#
public partial class New_Admin_Master : System.Web.UI.MasterPage
{
    MessageBox msg = new MessageBox();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["loguname"] == null && Session["BranchId"] == null)
            {
                Response.Redirect("../Login.aspx");
                msg.ShowAlertMessage("Session Expired");
            }
        }
    }
}

it works,but i need to check the session values every second,once the session value reached null then i have to show message like("Session Expired") in my Popup box,after clicking Ok in Alert box, it should redirect me to my login page.
How do i change my code to get this result?
Posted
Updated 25-Oct-14 1:41am
v2

The problem is that once the session expires, that breaks communication between the client and the server - so you can't use C# (server) code to show a alert box!

You are much, much better doing this in Javascript: if the user does nothing for a period of time, kill the session and show the alert from there.
 
Share this answer
 
Comments
Rajesh waran 25-Oct-14 7:56am    
Ok,thank you sir.
 
Share this answer
 
Comments
Rajesh waran 25-Oct-14 9:03am    
thank you,let me try
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900