If you are using ASP.NET Form Authentication redirect URL, you will come across a situation when you click logout form a page, you will be redirected to login page and your redirect url will be logout. So when you login, you will be immediately logged out since your redirect url is logout. To avoid this check if your redirect url is logout in the login view as follows;
@{
var redirectURL = FormsAuthentication.GetRedirectUrl(User.Identity.Name, true);
if (redirectURL == Url.Action("Logout", "User"))
{
redirectURL = "";
}
}
<form id="login-form" action="@Url.Action("Login", "User")" method="post">
<input type="hidden" value="@redirectURL" name="RedirectURL" />
...
</form>
No comments:
Post a Comment