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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:10:33+00:00 2026-06-13T19:10:33+00:00

Setup: I have designed a Wizard (based initially on Steve Sanderson’s wizard in Pro

  • 0

Setup:

I have designed a Wizard (based initially on Steve Sanderson’s wizard in Pro ASP.NET MVC 2).

Essentially, the base wizard controller is declared as follows:

public abstract class WizardController<TModel> : Controller where TModel : class, IWizardModel, new()
{
   // Loads-n-loadsa-code
}

To implement my wizard, therefore, I need to declare my Wizard controller as follows:

[WizardOptions(StartLabel="Edit >>")]
public partial class EditFeeEarnerController : WizardController<MyApp.Models.MySpecificWizardModel>
{
     // small amounts of highly intuitive code
}

Where MyViewModel implements IWizardModel.

So far so good. The wizard works beautifully and I am right chuffed with it, so don’t get hung up on that.

The issue follows:

Issue:

The only issue is that my Wizard uses partial views for each step, that get “stitched” together with a view (Wizard.cshtml).

Wizard.cshtml is ALWAYS the same for ANY wizard EXCEPT for the @model declaration at the top, in my example:

@model MyApp.Models.MySpecificWizardModel

As a result, in an app with 20 wizards, I have the very same file appearing 20 times.

Definitely not DRY.

Question:

I would like to put a file in ~/Views/Shared/Wizard.cshtml and use that for all my wizards. The reason I can’t do that is because I only know in advance that my wizard viewmodels will inherit from IWizardModel.

And I can’t do this:

@model IWizardModel

So what is the best way to do this, or is it just not possible?

I suppose I could have a base Wizard viewmodel that all my wizard viewmodels inherit from (instead of directly implementing IWizardModel).

Would this work?

EDIT (With the benefit of hindsight):

For the record, my problem was that I was misguided in thinking that using an interface as my model, ie, @model IWizardModel, wouldn’t work. As Iain Galloway pointed out in his answer, it does and that solved my problem.

The reason I thought I couldn’t use an interface as my model is that I did the following:

@model IWizardModel // MyNamespace.MySpecificWizardModel

The problem is the comment to the right (I commented out the old model).

For some reason, the comment generated an error (something to do with the ViewEngine). In my haste, I just presumed you couldn’t use interfaces for the model.

As olde Will said: Great is thy power, oh delay.

See Iain Galloway’s answer and my Addendum to it.

  • 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-13T19:10:34+00:00Added an answer on June 13, 2026 at 7:10 pm

    I’ve just tested the following:-

    public interface IModel
    {
        string Value { get; }
    }
    
    public class Foo : IModel
    {
        public string Value { get; set; }
    }
    
    public class HomeController : Controller
    {
        public ActionResult GenericView()
        {
            return View(new Foo() { Value = "Foo" });
        }
    }
    

    Along with GenericView.cshtml:-

    @model MvcApplication1.Models.IModel
    
    <h2>@Model.Value</h2>
    

    This appears to be working for me. Am I missing something important in your requirements?

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

Sidebar

Related Questions

The Setup I have designed a very easy to use MVC wizard. The cherry
We have an existing Firebird database which we wish to setup in an ASP.NET
I have a small Spring MVC webapp (which embeds ActiveMQ) that is designed to
I am new to ASP.NET MVC so wondering if anyone could provide tips on
I have an application that I've developed in .NET 4.0/C#. It's designed to be
The setup So I have a class, ComputerItem , designed to store everything I
I'm using Qt and I have a QTabWidget setup in the Qt Designer Editor,
Setup: I have a COM DLL that calls a method inside a managed C#
Setup : I have a Struts web application where I use displaytag elements to
Setup: I have a UITextView inside a UITableViewCell 's contentView . I want it

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.