This is probably again a newbie question.
When I create an ASP.NET MVC2 application, an Account Controller with an Action LogIn is created like this:
[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (MembershipService.ValidateUser(model.UserName, model.Password))
{
FormsService.SignIn(model.UserName, model.RememberMe);
if (!String.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
Now, I don't want to have a login page, I want to have login controls as part of a bigger page. So, I changed Login.aspx to Login.ascx and I am integrating it in my main view either with Html.RenderPartial or Html.RenderAction.
Both works like a charm if the login is successfull. If it is not, the
return View(model)
is killing me. What I want is to go back to my main page (call it Home/Index) but with the error information of the partial view.
return RedirectToAction("Index", "Home")
Obviously doesn't work.
Hints?