MVC
The Following javascript file put in Layout Page(Views/Shared/_layout.cshtml ) on MVC page.
<script type="text/javascript">
rootUrl = '@Url.Content("~/")';
var t;
window.onload = resetTimer;
document.onkeypress = resetTimer;
function logout() {
// alert("You are now logged out.")
// location.href = 'Logoff.php'
window.location.href = '@Url.Action("Login", "Register")';
}
function resetTimer() {
clearTimeout(t);
// t = setTimeout(logout, 60000) //logs out in 1 min
t = setTimeout(logout, 600000) //logs out in 10 min
}
</script>
================
Web Page(ASP.NET)
The Following javascript file put on Master Page.(MasterPage.master) on ASP.NET Site
<script type="text/javascript">
var t;
window.onload = resetTimer;
document.onkeypress = resetTimer;
function logout() {
// alert("You are now logged out.")
// location.href = 'Logoff.php'
//window.location.origin : you'll get http://sub.domain.com *****
window.location.href = window.location.origin+"/Account/login";
}
function resetTimer() {
clearTimeout(t);
// t = setTimeout(logout, 60000) //logs out in 1 min
t = setTimeout(logout, 600000) //logs out in 10 min
}
The Following javascript file put in Layout Page(Views/Shared/_layout.cshtml ) on MVC page.
<script type="text/javascript">
rootUrl = '@Url.Content("~/")';
var t;
window.onload = resetTimer;
document.onkeypress = resetTimer;
function logout() {
// alert("You are now logged out.")
// location.href = 'Logoff.php'
window.location.href = '@Url.Action("Login", "Register")';
}
function resetTimer() {
clearTimeout(t);
// t = setTimeout(logout, 60000) //logs out in 1 min
t = setTimeout(logout, 600000) //logs out in 10 min
}
</script>
================
Web Page(ASP.NET)
The Following javascript file put on Master Page.(MasterPage.master) on ASP.NET Site
<script type="text/javascript">
var t;
window.onload = resetTimer;
document.onkeypress = resetTimer;
function logout() {
// alert("You are now logged out.")
// location.href = 'Logoff.php'
//window.location.origin : you'll get http://sub.domain.com *****
window.location.href = window.location.origin+"/Account/login";
}
function resetTimer() {
clearTimeout(t);
// t = setTimeout(logout, 60000) //logs out in 1 min
t = setTimeout(logout, 600000) //logs out in 10 min
}
</script>
No comments:
Post a Comment