Automatically redirect User after some interval in ASP.Net

Last Reply one year ago By AnandM

Posted one year ago

Hi this is siddu

I want to stop the auto refresh when there 

is   key press and mouse click event in Asp..net withj C#

i used link

http://stackoverflow.com/questions/4644027/how-to-automatically-reload-a-page-after-a-given-period-of-inactivity

but not work for me pleasem let us know

The solution

  <head>
       <meta http-equiv="refresh" content="60" />
<script type="text/javascript">
    var time = new Date().getTime();
    $(document.body).bind("mousemove keypress", function (e) {
        time = new Date().getTime();
    });

    function refresh() {
        if (new Date().getTime() - time >= 60000)
            window.location.reload(true);
        else
            setTimeout(refresh, 10000);
    }

    setTimeout(refresh, 10000);
</script>
       
</head>

 

  if (Session["user"] != null && Session["test"] != null)
        {
            // let them access the page.

            Label1.Text = "Welcome " + Session["test"].ToString();
        }
        else
        {
            //clear the cache and  redirect back to login page.
            Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetNoStore();
            Session.Abandon();
            Response.Redirect("Default.aspx");
        }

 

Posted one year ago

Hi siddu,

Can you explain in more detail exactly what you are trying to achieve if possible explain with an example


Posted one year ago

Hi Annad

I am doing

as when user after login if he idle for 1 min it should re direct to 

again login Page. if user after login he is doing  filling the form  details

which he redirectd , i want to stop the auto refresh after 1 min

if he  doing some thing

otherwise page will move to auto refresh and redirect to login page

again


I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html