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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:16:28+00:00 2026-06-05T07:16:28+00:00

I have a multi step wizard that I have pieced together from useful posts

  • 0

I have a multi step wizard that I have pieced together from useful posts like this its got a few problems however.. here’s the setup I have

[Serializable]
public class WizardModel
{

    public IList<IStepViewModel> Steps 
    { 
        get; 
        set; 
    }
    public void Initialize()
    {
        Steps = typeof(IStepViewModel)
            .Assembly
            .GetTypes()
            .Where(t => !t.IsAbstract && typeof(IStepViewModel).IsAssignableFrom(t))
            .Select(t => (IStepViewModel)Activator.CreateInstance(t))
            .ToList();
    }

}

My Wizard controller

    public ActionResult Index()
    {
        var wizard = new WizardModel();     
        wizard.Initialize();
        //this populates wizard.Steps with 3 rows of IStepViewModel
        return View(rollover);       
    }

    [HttpPost]
    public ActionResult Index(
        [Deserialize] WizardModel wizard,
        IStepViewModel step
        )
    {
        //but when this runs wizard is a new class not the one previously Initialized
         wizard.Steps[rollover.CurrentStepIndex] = step;
    }

My issue is that wizard is a fresh object each time its posted – when I’m trying to pass the same model around populating each step in the array. Does anyone have an idea of where I’m going wrong here?

Here’s the ModelBinding

Global.asax

   ModelBinders.Binders.Add(typeof(IStepViewModel), new FormTest.Models.StepViewModelBinder());

and

  public class StepViewModelBinder : DefaultModelBinder
{
    protected override object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
    {
        var stepTypeValue = bindingContext.ValueProvider.GetValue("StepType");
        var stepType = Type.GetType((string)stepTypeValue.ConvertTo(typeof(string)), true);
        var step = Activator.CreateInstance(stepType);
        bindingContext.ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => step, stepType);
        return step;
    }
}

Thanks in advance

Edit:

if I understand, an alternative to using session is to serialize my model (below), and deserialize in my controller action. I set the values on the model that were posted to the controller .. which gets returned to the view for the next step and so on.. until the final step when I have a wizard model populated with each step.

Index.cshtml

   @using (Html.BeginForm())
   {
         @Html.Serialize("wizard", Model);  
         etc...
   }   

so the wizard parameter that I try deserialize here

    [Deserialize] WizardModel wizard,

comes through the controller post action is a new object each time – I would like to see if this is possible without using Session but @Html.Serialize? and Post

  • 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-05T07:16:29+00:00Added an answer on June 5, 2026 at 7:16 am

    This code did the job in the end. Inside the controller action,

            var serializer = new MvcSerializer();
            var value = Request["wizard"];
            var wizard = (WizardModel)serializer.Deserialize(value, SerializationMode.Signed);
    

    And in the view

        @Html.Serialize("wizard", Model, SerializationMode.Signed);   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multi-step form (a wizard) that I created using this railscast: http://railscasts.com/episodes/217-multistep-forms
I have got a the following problem: I have got multi-step form where in
I'm doing a multi step form (form wizard) and I have splitted the form
I have a Cocoa app with a custom, multi-step account setup that I implemented
I have a large multi-step form that will insert a record into a database.
So I have a multi-step process that allows a user to retrieve a forgotten
I have a multi-step order form built in this manner: Step 1: Choose category
I have a multi-step BackgroundWorker process. I use a marquee progress bar because several
I have a multi-step form where the form on Step3 submits to Step4.php. Step4
I have a longer running multi-step process using BackgroundWorker and C#. I need to

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.