【问题标题】:Logout user from JS function in Layout view从布局视图中的 JS 函数注销用户
【发布时间】:2016-12-12 04:07:24
【问题描述】:

我在 https://github.com/rigoneri/timeout-dialog.js 的 asp.net MVC Web 应用程序中使用 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>
 }

注意“logout_redirect_url:'../Account/LogOff'”部分,Account 是 Controller,LogOff 是 Action。倒计时计时器按预期显示,但它不会重定向到 LogOff 操作并再次重新加载活动页面。

我在这里做错了吗?

【问题讨论】:

    标签: jquery asp.net-mvc session c#-4.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>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-03
      • 1970-01-01
      • 1970-01-01
      • 2019-08-30
      • 1970-01-01
      • 2020-10-02
      • 1970-01-01
      相关资源
      最近更新 更多