I have a session expiring method that logs out a user after 20 mins using a countdown from a cookie. It works fine as the user does successfully get logged out. The only issue is the URL after appears as
localhost:8091/Login?ReturnUrl=%2FLogin%2FLogOut
when it shouldn't have anything after /Login. I am using C# and ASP.NET 4 with MVC's.
This is the JS used to redirect the user...
function startCountdown(timeLeft) {
if (countDownInterval > 0) return;
$('#idletimeoutcount').text(countDown);
$('#idletimeout').slideDown();
countDown = parseInt(timeLeft / 1000);
countDownInterval = setInterval(function() {
$('#idletimeoutcount').text(countDown);
var secondsLeft = countDown--;
document.title = "Warning! " + secondsLeft + " seconds left until logged out";
if (countDown <= 0) {
// console.log('finished');
window.location.href = '/Login/LogOut';
}
}, 1000);
}
And the LogOut function:
public ActionResult LogOut()
{
FormsAuthentication.SignOut();
return RedirectToAction("Index", "Login");
}
Is there any way to make it so the url is localhost:8091/Login ? (HTTP taken out because of stack overflow)
It might be something to do with the web config which contains these tags:
<authentication mode="Forms">
<forms name="SqlAuthCookie" loginUrl="Login" timeout="20" slidingExpiration="true" />
</authentication>