I am using Forms Auhtentication in MVC4, my problem is that users are not redirect from login page after authentication.
Below is my Login Action:
[HttpPost]
public ActionResult Login(LoginModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (Membership.ValidateUser(model.UserName, model.Password))
{
FormsAuthentication.SetAuthCookie(model.UserName,model.RememberMe);
RedirectToDefault(returnUrl,model.UserName);
}
else
{
this.ShowMessage(MessageType.Danger, "Invalid username or password.");
}
}
this.ShowMessage(MessageType.Danger, "Invalid username or password.");
return View(model);
}
and my Web.Config :
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
This code :
FormsAuthentication.SetAuthCookie(model.UserName,model.RememberMe);
RedirectToDefault(returnUrl, model.UserName);
are executed but the code still got the last Return View(model);
Please any help will be appreciated.
RedirectToDefault, useRedirectToActionand point it toward your index page?