I have a problem where the user is logged out all the time even though the function logout hasn't been executed. It seems like this is due to the code being in c# (this is in a razor layout page mvc4)
<script type="text/javascript">
var idleTimer = 0;
function notIdle()
{
clearTimeout(idleTimer);
idleTimer = setTimeout(function () { logout() }, 5000);
}
function logout()
{
@if (Request.IsAuthenticated )
{
WebSecurity.Logout();
}
window.location.reload();
clearTimeout(idleTimer);
}
</script>