在布局视图

时间:2016-08-05 16:58:25

标签: jquery asp.net-mvc session c#-4.0

我在https://github.com/rigoneri/timeout-dialog.js的asp.net MVC网络应用中使用Timeout Dialouge插件显示会话超时弹出倒计时。

在我的布局页面中,我有以下JS调用:

 @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 }); });
    </script>
 }

注意&#34; logout_redirect_url:&#39; ../ Account / LogOff&#39;&#34;部分,帐户是控制器&amp; LogOff是Action。倒数计时器按预期显示,但不会重定向到LogOff操作并重新加载活动页面。

我在这里做错了吗?

1 个答案:

答案 0 :(得分:1)

此插件已有5年历史,不再维护。

您遇到的问题是jQuery库:如果您使用此插件开发时可用的库,则效果很好:

$(function () {
  $.timeoutDialog({
    timeout: 1,
    countdown: 5,
    logout_redirect_url: '../Account/LogOff',
    restart_on_yes: false
  });
});
<link rel="stylesheet" href="https://rawgit.com/rigoneri/timeout-dialog.js/master/css/timeout-dialog.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"></script>
<script src="https://rawgit.com/rigoneri/timeout-dialog.js/master/js/timeout-dialog.js"></script>