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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:09:33+00:00 2026-06-01T01:09:33+00:00

All, I’m new to MVC and therefore learning it as I go along by

  • 0

All,

I’m new to MVC and therefore learning it as I go along by working on a new project. I have some simple functionality I would like to achieve but don’t know if I’m doing it the correct way – the current approach results in a runtime error – a description of the problem is below.

I’m trying to create some password reset functionality. To reset a password, I’m going to get the user to enter their username and e-mail on one view. Then on a second view I’m going to display their password reset question and get them to enter their password reset answer. The second view will also display their username, so I need to pass the entered username from view one into view two. I have the following two models so far:

public class ResetPasswordModelStepOne
{
    [Required]
    [Display(Name = "Username")]
    public string Username { get; set; }

    [Required]
    [Display(Name = "Email")]
    [DataType(DataType.EmailAddress)]
    public string Email { get; set; }
}

public class ResetPasswordModelStepTwo
{
    public ResetPasswordModelStepOne StepOneModel { get; set; }

    [Display(Name = "Question")]
    public string ResetQuestion { get; set; }

    [Required]
    [Display(Name = "Answer")]
    public string ResetAnswer { get; set; }
}

Notice that the second model also has a property to store the step one model, this is so that on the second view, I can access and display the users username in a message like “Hi {Username}, to reset your password, please answer your password reset question.”. I have created strongly typed views for both the above models and have the following actions.

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

    [HttpPost]
    public ActionResult PasswordResetStepOne(ResetPasswordModelStepOne stepOneModel)
    {
        //Imagine i'm validating that the user exists here and then retrieving
        //their secret question from a repository
        var userSecretQuestion = "What is your favourite color?";

        return PasswordResetStepTwo(new ResetPasswordModelStepTwo { StepOneModel = stepOneModel, ResetQuestion = userSecretQuestion });
    }

    public ActionResult PasswordResetStepTwo(ResetPasswordModelStepTwo stepTwoModel)
    {
        return View(stepTwoModel);
    }

The problem I’m having with this approach is that when the user enters their username and email on the first step view, I then call the “PasswordResetStepTwo” action which returns the strongly typed view for ResetPasswordModelStepTwo – this results in the following runtime error:

The model item passed into the dictionary is of type
‘MvcCrossPageModel.Models.ResetPasswordModelStepTwo’, but this
dictionary requires a model item of type
‘MvcCrossPageModel.Models.ResetPasswordModelStepOne’.

Can someone explain what I’m doing wrong here? Is there a better way to achieve this in one view with one model? Am I doing this correctly by creating “step one” and “step two” models? Ideally I’d like to have a single view, the user enters their username and email – then the same view is returned prompting them for their secret question/

  • 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-01T01:09:34+00:00Added an answer on June 1, 2026 at 1:09 am
    every strongly typed views has one model. But you have two ways.
    Razor syntax
    1.Use this view.
        @model dynamic
        <div>
        any html
        @(using Html.BeginForm()){
        @Html.EditorForModel()
        <button type="submit">save</button>
        }
        </div>
    
    2. Use two views
    
    public ActionResult PasswordResetStepOne()
        {
            return View();
        }
    
        [HttpPost]
        public ActionResult PasswordResetStepOne(ResetPasswordModelStepOne stepOneModel)
        {
            //Imagine i'm validating that the user exists here and then retrieving
            //their secret question from a repository
            var userSecretQuestion = "What is your favourite color?";
    
            return PasswordResetStepTwo(new ResetPasswordModelStepTwo { StepOneModel = stepOneModel, ResetQuestion = userSecretQuestion });
        }
    
        public ActionResult PasswordResetStepTwo(ResetPasswordModelStepTwo stepTwoModel)
        {
            return View("NextViewName",stepTwoModel);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All - Need some insight into this issue. I have created a sample project
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
all. We're trying to get some intersect collisions working, but the problem experience is
I have just tried to save a simple *.rtf file with some websites and
All, We could really do with some advice from SVG gurus. WHAT WE HAVE:
All , Say you have a code in a View like this. <img src='@Url.Action(GetCaptchaImg)'
All, If I run a query like the following: $qry = Select wrong_column from
All -- I have these two methods in one of my classes: public static
All my code is here,quite simple,and I don't konw where it goes wrong. Person
All of a sudden, Facebook sharing has stopped working on my site. It's been

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.