The model item passed into the dictionary is of type 'Umbraco.Web.Models.RenderModel', but this dictionary requires a model item of type 'Umbraco6Mvc.Models.MemberRegisterModel'.
I use Umbraco 6.1.6 and my code is as follows:
Child action call in template:
@Html.Action("RegisterForm", "Member")
Model:
public class MemberRegisterModel
{
[Required, Display(Name = "Enter your name")]
public string Name { get; set; }
[Required, Display(Name = "Enter your email")]
[RegularExpression(SiteHelpers.EmailRegExp, ErrorMessage = "Invalid email.")]
public string Email { get; set; }
[Required, Display(Name = "Password"), DataType(DataType.Password)]
public string Password { get; set; }
}
Controller:
public class MemberController : SurfaceController
{
[ChildActionOnly]
public ActionResult RegisterForm()
{
return PartialView("register", new MemberRegisterModel());
}
[HttpPost]
public ActionResult Register(MemberRegisterModel model)
{
if (!ModelState.IsValid)
{
return CurrentUmbracoPage();
}
}
}
It states in the documentation that to avoid the problem I should use different names for action or attribute post action with [NotChildAction] but neither of those work for me. What am I missing and how can I avoid that?
Model problem with MVC form in Child action
Hi Guys, I'm trying to follow this tutorial http://our.umbraco.org/documentation/reference/Mvc/forms/turorial-child-action but keep getting YSOD when I call
return CurrentUmbracoPage();
:The model item passed into the dictionary is of type 'Umbraco.Web.Models.RenderModel', but this dictionary requires a model item of type 'Umbraco6Mvc.Models.MemberRegisterModel'
.I use Umbraco 6.1.6 and my code is as follows:
Child action call in template:
Model:
Controller:
View:
It states in the documentation that to avoid the problem I should use different names for action or attribute post action with
[NotChildAction]
but neither of those work for me. What am I missing and how can I avoid that?Thanks
Ok, I found the problem, my partial view name was Register (same as HttpPost method name) and apparently it conflicted somehow.
I renamed the view to "RegisterForm" and changed my get action method accordingly:
Just posting it here in case someone has the same problem.
Zakhar.
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.