Robin Robin - 1 year ago 117
jQuery Question

Logout user from JS function in Layout view

I am using Timeout Dialouge plugin in MVC web app from for showing a session timeout popup countdown.

In my layout page I have following JS call:

@if (User.Identity.IsAuthenticated)
<script type="text/javascript">
$(document).ready(function () { $.timeoutDialog({ timeout: 1200, countdown: 60, logout_redirect_url:'../Account/LogOff', restart_on_yes: false }); });

Notice the "logout_redirect_url:'../Account/LogOff'" part, Account is Controller & LogOff is Action. The countdown timer shows as expected but it does not redirects to LogOff action and reloads the active page again.

Am I doing something wrong here?

Answer Source

This plugin is 5 years old and no more maintained.

The problem you are experiencing is with the jQuery libraries: if you use the libraries available when this plugin was developed it works well:

$(function () {
    timeout: 1,
    countdown: 5,
    logout_redirect_url: '../Account/LogOff',
    restart_on_yes: false
<link rel="stylesheet" href="">
<script src=""></script>
<script src=""></script>
<script src=""></script>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download