我有一个 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
页面时,用户退出并且他的会话被放弃?