Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when we copy the url to another browser it should be redirected to login page ,am using lik this ,But if user stay on the same page without doing any action it displays error msg.how to maintain the session time

Here is my code:
in Global.asax

C#
        protected void Session_Start(object sender, EventArgs e)
        {
            Response.Redirect(Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~\\Home.aspx"));
        }

        protected void Session_End(object sender, EventArgs e)
        {
            Response.Redirect(Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~\\Home.aspx"));
        }
    }
}
Posted
Updated 28-Jan-12 2:51am
v3
Comments
[no name] 28-Jan-12 8:41am    
Format your snippets and only include relevant pieces, not all.

 
Share this answer
 
If you want to keep the session alive there must be some activity from the browser. Remember this is a stateless environment and once the page is served the server forgets about it. It doesn't know if the browser was closed, navigated to another site or the use went to lunch. You could use an AJAX method to asynchronously call a method so the session timeout would reset. Although, having a session timeout has a purpose and you should evaluate your need before overriding it.
 
Share this answer
 

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