This is a migrated thread and some comments may be shown as answers.

Javascript disabled after a period of user inactivity

1 Answer 138 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kevin
Top achievements
Rank 1
Kevin asked on 08 Jul 2011, 10:02 PM

I have built an internal application for our company's users. There is no timeout after user inactivity nor do we want one. Users are complaining that after a certain amount of time (like 30 minutes) of inactivity, the web app starts acting strange if the start to use it again. Buttons don't work, combo boxes will not drop down, datepickers are broke. It seems very clear to me that the Javascript is getting disabled after period of user inactivity.

Has anybody come across this behavior and if so, how do I prevent it?

The web app is an ASP.NET MVC 3.0 app, using the Telerik MVC Extensions, which includes writing some client side Ajax. It is running on IIS 6.0 on Windows Server 2003 Standard Edition.

Thanks, Steve

1 Answer, 1 is accepted

Sort by
0
John DeVight
Top achievements
Rank 1
answered on 11 Jul 2011, 02:22 PM
Hey Steve,

I wonder if the problem has something to do with the session timing out...

I had to implement a "keep alive" call in an application last year that involved a significant amount of time in between each postback.  The application was developed as an ASP.NET WebForms application and I used an AJAX Timer control to periodically postback to the server.

An idea using a jQuery.ajax call would be to:
1. In the Html.Telerik().ScriptRegistrar().OnDocumentReady() function, use the javascript setInterval function to periodically call a function that would make the jQuery.ajax call.
2. Have the jQuery.ajax make a call to a function defined in a controller.

Here is the code for the Html.Telerik().ScriptRegistrar().OnDocumentReady() function that could be defined in the Site.Master page:

<%
    Html.Telerik().ScriptRegistrar().DefaultGroup(group => group.Combined(true).Compress(true))
        .OnDocumentReady(() =>
        {%>
            setInterval("keepAlive()", 300000);
        <%})
        .Render();
%>

Here is the keepAlive() javascript function:

<script type="text/javascript">
    keepAlive = function() {
        $.ajax({
            url: '/Home/KeepAlive',
            success: function(data) {
                console.log(data);
            }
        });
    }
</script>

Here is the KeepAlive method defined in the HomeController:

public class HomeController : Controller
{
    public JsonResult KeepAlive()
    {
        return Json(new { result = "Alive" }, JsonRequestBehavior.AllowGet);
    }
}

Hope this helps...

Regards,

John DeVight
Tags
General Discussions
Asked by
Kevin
Top achievements
Rank 1
Answers by
John DeVight
Top achievements
Rank 1
Share this question
or