Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi, i have below controller for user login:
public ActionResult DoLogin(myLoginViewModels model) { if (ModelState.IsValid) { if (validateUserAccount(model)) { TempData["LoginSuccess"] = true; FormsAuthentication.SetAuthCookie(model.User, false); return RedirectToCurrentUmbracoPage(); } else { TempData["Status"] = "Invalid Log-in Credentials"; TempData["LoginSuccess"] = false; return CurrentUmbracoPage(); //return View(model); } } return CurrentUmbracoPage(); }
and i try to show TempData["Status"] in my form if login failed, but i don' know how to do this, below is my template :
<div class="container"> @if (TempData["LoginSuccess"] != null && (bool)TempData["LoginSuccess"]) { Html.RenderAction("RenderForm", "myMember"); } else { Html.RenderAction("RenderForm", "myLogin"); } </div>
Hi Wilson
What is the value of TempData["LoginSuccess"] if you debug?
Thanks,
Alex
refer to my controller, if validateUserAccount return true, it will execute
TempData["LoginSuccess"] = true;
and if false, TempData["LoginSuccess"] will never create and have null value.
when come to Template,
@if (TempData["LoginSuccess"] != null && (bool)TempData["LoginSuccess"])
is working as expected and manage to RenderAction.
Hi In this tutorial, I use the approach of adding a ModelError to the ModelState and returning the current Umbraco Page.
That way the error will show in the validation summary
http://www.codeshare.co.uk/blog/tutorial-how-to-create-member-login-and-logout-form-in-umbraco-mvc/
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
show message in form when Login Failed
Hi, i have below controller for user login:
and i try to show TempData["Status"] in my form if login failed, but i don' know how to do this, below is my template :
Hi Wilson
What is the value of TempData["LoginSuccess"] if you debug?
Thanks,
Alex
refer to my controller, if validateUserAccount return true, it will execute
TempData["LoginSuccess"] = true;
and if false, TempData["LoginSuccess"] will never create and have null value.
when come to Template,
@if (TempData["LoginSuccess"] != null && (bool)TempData["LoginSuccess"])
is working as expected and manage to RenderAction.
Hi In this tutorial, I use the approach of adding a ModelError to the ModelState and returning the current Umbraco Page.
That way the error will show in the validation summary
http://www.codeshare.co.uk/blog/tutorial-how-to-create-member-login-and-logout-form-in-umbraco-mvc/
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.