I'm creating a mvc login form for existing Umbraco site
I'm using Html.BeginUmbracoForm on the View, SurfaceController is called, but it fires "Can only use UmbracoPageResult in the context of an Http POST when using a SurfaceController form" exception
My SurfaceController:
[HttpGet]
[ActionName("MemberLogin")]
public ActionResult MemberLoginGet()
{
return View("MemberLogin", new MemberLoginModel());
}
// The MemberLogout Action signs out the user and redirects to the site home page:
[HttpGet]
public ActionResult MemberLogout()
{
Session.Clear();
FormsAuthentication.SignOut();
return Redirect("/");
}
[HttpPost]
[ActionName("MemberLoginPost")]
public ActionResult MemberLoginPost(MemberLoginModel model)
{
if (ModelState.IsValid && !MembersManager.IsMemberSponsor(model.Username))
{
result = MembersManager.AuthenticateUser(model.Username, model.Password);
if (result.IsAuthenticated)
{
model.Username = MembersManager.GetActualLoginString(model.Username);
FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe);
return RedirectToUmbracoPage(32684);
}
else
{
return View("MemberLogin");
}
}
else
{
return CurrentUmbracoPage();
}
}
Problems with Html.BeginUmbracoForm
I'm creating a mvc login form for existing Umbraco site I'm using Html.BeginUmbracoForm on the View, SurfaceController is called, but it fires "Can only use UmbracoPageResult in the context of an Http POST when using a SurfaceController form" exception
And the View:
What should I do?
I think it might be your line: returnView("MemberLogin");
Try changing that to returnCurrentUmbracoPage();
Andy
Are you in the context of a partial view when you post to the controller? If so you need to return a partial view.
You also need to pass a new instance of MemberLoginModel into the View("MemberLogin)
Charlie :)
is working on a reply...