Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9291595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:41:06+00:00 2026-06-18T20:41:06+00:00

Even though that i believe that i have all the models defined and hopefully

  • 0

Even though that i believe that i have all the models defined and hopefully passed in properly but i am getting an error which states that i am passing in one model when it requires another model.

Main View:

@model Project.Models.ProfileModel

 @(ViewBag.HasLocalPassword ? Html.Partial("_ChangePasswordPartial", Model.PasswordModel) : Html.Partial("_SetPasswordPartial", Model.PasswordModel))

            @Html.Partial("_UsernamePartial", Model.UsernameModel)
            @Html.Partial("_PlayNamePartial", Model.PlayNameModel)

Models:

 public class ProfileModel
{
    public PasswordModel PasswordModel { get; set; }
    public PlayNameModel PlayNameModel { get; set; }
    public UsernameModel UsernameModel { get; set; }
}

UserName Action GET:

public ActionResult _UsernamePartial()
    {
        var usernameModel = new UsernameModel();
        using (var db = new DataContext())
        {
            usernameModel.Username =
                (from u in db.Users where u.ID == WebSecurity.CurrentUserId select u.Username).FirstOrDefault();
        }
        return PartialView(usernameModel);
    }

UserName POST Action:

[HttpPost]
    public ActionResult _UsernamePartial(UsernameModel usernameModel)
    {
        if (ModelState.IsValid)
        {
            using (var db = new DataContext())
            {
                User user = db.Users.FirstOrDefault(u => u.ID == WebSecurity.CurrentUserId);
                user.Username = usernameModel.Username;
                db.SaveChanges();
            }
        }
        return View("_UsernamePartial");
    }

Profile Action:

public ActionResult Profile(ManageMessageId? message)
    {
        var profile = New ProfileModel();
        ViewBag.StatusMessage =
            message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
            : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
            : message == ManageMessageId.RemoveLoginSuccess ? "The external login was removed."
            : "";
        ViewBag.HasLocalPassword = OAuthWebSecurity.HasLocalAccount(WebSecurity.GetUserId(User.Identity.Name));
        ViewBag.ReturnUrl = Url.Action("Profile");
        return View(profile);


    }

View Page for UserName:

@model Acatar.Models.UsernameModel

@using (Html.BeginForm("_UsernamePartial", "Account")) {

       <p id="legend">Username</p>
       @Html.TextBoxFor(m=>m.Username)

    <button type="submit" value=" Username">Save</button>
}

Error Message: The model item passed into the dictionary is of type 'Project.Models.ProfileModel', but this dictionary requires a model item of type 'Project.Models.UsernameModel'.

Would really appreciate any help of where i am going wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T20:41:07+00:00Added an answer on June 18, 2026 at 8:41 pm

    If you call Html.Partial I don’t believe that it invokes the action method. You should be using Html.RenderAction() which will invoke the controller action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem of web pages being cached even though I specify that
I'm using the i18n feature of Django. I have noticed that even though I
Even though I have a fermi card(gtx 560) I get this error on VS2010:
I believe that all of these (and even die() or die(0) ) are identical.
First of all I'm rather new to SQL and so even though I believe
One would expect that even though strings are immutable, value-equality and reference-equality would not
Even though it's not part of HTTP 1.1/RFC2616 webapps that wish to force a
MS's OneNote uses a data hierarchy that is essentially a simple tree, even though
This is my first question on the site even though i have been coming
First, the topic. I have three models, which are linked between each other with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.