I keep getting different errors when trying to load a partial view, I am not sure what to pass in my AdminProfile controller, some of the errors I have recieved:

The model item passed into the dictionary is of type 'System.Boolean', but this dictionary requires a model item of type 'BlaBla.Models.LocalPasswordModel'.

Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'System.Boolean', but this dictionary requires a model item of type 'BlaBla.Models.LocalPasswordModel'.

AdminProfile View:

@Html.Action("~/Views/Account/Manage.cshtml")

AdminProfile Controller:

    public ActionResult AdminProfile()
    {
        return View();
    }

I am trying to display this controller:

    public ActionResult Manage(LocalPasswordModel model)
    {
        bool hasLocalAccount = OAuthWebSecurity.HasLocalAccount(WebSecurity.GetUserId(User.Identity.Name));
        ViewBag.HasLocalPassword = hasLocalAccount;

and View for manage, this will display either changepassword partial or set password if no password is set:

@model LocalPasswordModel
@{
    ViewBag.Title = "Change Password";
}

@if (ViewBag.HasLocalPassword)
{
    @Html.Partial("_ChangePasswordPartial")
}
else
{
    @Html.Partial("_SetPasswordPartial")
}

LocalPasswordModel:

public class LocalPasswordModel
{
    [Required]
    [DataType(DataType.Password)]
    [Display(Name = "Current password")]
    public string OldPassword { get; set; }

    [Required]
    [RegularExpression(@"^((?=.*[a-z])(?=.*[A-Z])(?=.*\d)).+$", ErrorMessage = "Password must have at least one uppercase and lowercase letters, and digit.")]
    [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
    [DataType(DataType.Password)]
    [Display(Name = "New password")]
    public string NewPassword { get; set; }

    [DataType(DataType.Password)]
    [Display(Name = "Confirm new password")]
    [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
    public string ConfirmPassword { get; set; }
}

Related posts

Recent Viewed