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 8128957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:06:29+00:00 2026-06-06T08:06:29+00:00

I’m new to the whole MVC 3 style coding. I’m running into an issue,

  • 0

I’m new to the whole MVC 3 style coding. I’m running into an issue, but first here’s how I have my website laid out.

_Layout.cshtml contains

        @if (Request.IsAuthenticated)
        {
            <div class="span2">
                @Html.Partial("_NavigationPartial")
            </div>
            <div class="span10">
                @RenderBody()
            </div>
        }
        else
        { 
            @RenderBody()
        }

@RenderBody will display my Profile.cshtml file that contains the following:

@{
    ViewBag.Title = "My Profile";
}
<div class="row-fluid well">
    <div class="page-header">
        <h1>
            Profile</h1>
    </div>
    @{ 
        Html.RenderPartial("ChangePersonalInformationPartial");
        Html.RenderPartial("ChangePasswordPartial");
        }
</div>

As you see, I have two Partials (One to change the Personal Information, the other to Change the Password).

Each one of these Partials uses it’s own Model (ChangePersonalInformationModel and ChangePasswordModel).

My problem comes when I click submit on my ChangePasswordPartial, it reloads the _Layout.cshtml page but this time only loads up ChangePasswordPartial.cshtml. I need it to load up Profile.cshtml. But, if I go ahead and change under my AccountController.cs the return View(); to return View("Profile"); I get an error saying:

The model item passed into the dictionary is of type
‘PROJECT.Models.ChangePasswordModel’, but this dictionary requires a
model item of type ‘PROJECT.Models.ChangePersonalInformationModel’.

How can I fix this problem?

Thanks!

  • 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-06T08:06:31+00:00Added an answer on June 6, 2026 at 8:06 am

    Basically you have to make a redirect to the profile action in the ChangePassword action once you saved the password information.

    UPDATE:

    First you should have a common model say ProfileModel that wraps up the ChangePasswordModel and ChangePersonalInformationModel.

    So here are the actions that displays the profile information for viewing and editing.

    // this action will returns a views that displays profile info
    public ViewResult Profile(string username)
    {
      ProfileModel model = .. get the profile from database based on username
    
      return View(model);
    }
    
    // this action will returns the profile info for editing or adding a new profile
    public ViewResult EditProfile(string username)
    {
       .. if the profile already exists get from database
       ProfileModel model = 
    
       .. if this is a new profile create an empty model
       ProfileModel model = new ProfileModel();
       model.ChangePasswordModel = new ChangePasswordModel();
       model.ChangePersonalInformationModel = new ChangePersonalInformationModel();
    
       return View(model);
    }
    

    Your EditProfile.cshtml will be like this

    @model Models.ProfileModel
    
    ...
    @{ 
       Html.RenderPartial("ChangePersonalInformationPartial", 
                                      Model.ChangePersonalInformationModel);
       Html.RenderPartial("ChangePasswordPartial", Model.ChangePasswordModel);
    }
    ...
    

    This will be your ChangePassword action

    [HttpPost]
    public ActionResult ChangePassword(ChangePasswordModel model)
    {
      if(ModelState.IsValid)
      {
         // save the ChangePasswordModel to database and display the profile info
         // or even you can redirect to EditProfile for more editing
         return RedirectToAction("Profile"); 
      }      
    
       .. there are validation errors so get the complete profile model from database
       .. the ChangePasswordModel form will be filled by the details entered in the form
       .. and not from the db details this will be taken care by the framework itself.
       ProfileModel model = 
       return View("EditProfile", model);     
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I am currently running into a problem where an element is coming back from
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.