提问人:gene 提问时间:6/8/2017 最后编辑:gene 更新时间:6/8/2017 访问量:132
MVC/Ajax:当使用“JavaScript”导航到某个页面时,如何放弃会话或从应用程序中注销?
MVC/Ajax:How to abandon session or log out from the application when a certain page is navigated to with `JavaScript`?
问:
我有一个 MVC 应用程序,当单击浏览器按钮时,我能够在浏览器历史记录中导航。Back
我有以下MVC代码来构建链接:
@Ajax.ActionLink("Page1", "Index","Page1",new AjaxOptions { HttpMethod = "GET", InsertionMode = InsertionMode.Replace, UpdateTargetId= "mainAjax", LoadingElementId="loader", OnComplete="ChangeUrl('Page1');" })
@Ajax.ActionLink("Page2", "Index", "Page2", new AjaxOptions { HttpMethod = "GET", InsertionMode = InsertionMode.Replace, UpdateTargetId = "mainAjax", LoadingElementId = "loader", OnComplete = "ChangeUrl('Page2');" })
@Ajax.ActionLink("Page3", "Index", "Page3", new AjaxOptions { HttpMethod = "GET", InsertionMode = InsertionMode.Replace, UpdateTargetId = "mainAjax", LoadingElementId = "loader", OnComplete = "ChangeUrl('Page3');" })
@Ajax.ActionLink("Page4", "Index", "Page4", new AjaxOptions { HttpMethod = "GET", InsertionMode = InsertionMode.Replace, UpdateTargetId = "mainAjax", LoadingElementId = "loader", OnComplete = "ChangeUrl('Page4');" })
这是为了处理历史的回溯:JavaScript
$(document).ready(function () {
$(window).bind('popstate', function () {
window.location.href = window.location.href;
});
});
function ChangeUrl(url)
{
document.title = $('.pageTitle').text() + ' - eSite'
window.history.pushState(null, null, url);
}
但是,当返回页面时,一旦我单击按钮,我就可以返回应用程序而无需经过身份验证。login
Forward
我该怎么办,以便当浏览器的历史记录返回页面时,用户的会话已注销并放弃其会话?Login
答: 暂无答案
评论