会话超时时关闭Jquery对话框

时间:2021-09-27 11:00:20

I am working with an ASP.NET MVC4 application which loads lot of jQuery dialogs with partial views in div on click events. I have come across an issue when the session times out, the application login page loads within the jQuery Dialog Popup.

我正在使用ASP.NET MVC4应用程序,该应用程序在点击事件的div中加载了大量jQuery对话框和部分视图。当会话超时时,我遇到了一个问题,应用程序登录页面在jQuery Dialog Popup中加载。

Is there any way to close the jQuery Dialog popup when the session has timed out so that they are returned to the actual application login page to re-authenticate?

当会话超时时,有没有办法关闭jQuery Dialog弹出窗口,以便它们返回到实际的应用程序登录页面以重新进行身份验证?

This is my Actionresult

这是我的Actionresult

if (Request.IsAuthenticated)
{
    try
    {
        // Do something
    }
    catch { throw; }
    finally
    {

    }
}
else
{
    return RedirectToAction("Index", "Home");
}

1 个解决方案

#1


0  

In your login page code detect if the session is stale, if so return something to reload the whole page in the browser.

在您的登录页面代码中检测会话是否过时,如果是,则返回一些内容以在浏览器中重新加载整个页面。

If you are using iframes, you can just return JS that adds the meta refresh to the page...

如果你正在使用iframe,你可以返回JS,将元刷新添加到页面......

<script>
    $(parent.document.getElementsByTagName('head')[0]).append('<meta http-equiv="refresh" content="0">');
</script>

If you are AJAXing directly into a div, you can just return the meta refresh tag and it should reload the page...

如果你直接在一个div中进行AJAX,你可以只返回元刷新标签,它应该重新加载页面...

<meta http-equiv="refresh" content="0">

#1


0  

In your login page code detect if the session is stale, if so return something to reload the whole page in the browser.

在您的登录页面代码中检测会话是否过时,如果是,则返回一些内容以在浏览器中重新加载整个页面。

If you are using iframes, you can just return JS that adds the meta refresh to the page...

如果你正在使用iframe,你可以返回JS,将元刷新添加到页面......

<script>
    $(parent.document.getElementsByTagName('head')[0]).append('<meta http-equiv="refresh" content="0">');
</script>

If you are AJAXing directly into a div, you can just return the meta refresh tag and it should reload the page...

如果你直接在一个div中进行AJAX,你可以只返回元刷新标签,它应该重新加载页面...

<meta http-equiv="refresh" content="0">