Bruno Machado - vargero
Bruno Machado - vargero

Reputation: 2730

How to create a configurable system in ASP.NET MVC 3?

The scenario is: the company where I work need to ship a product which it's features are defined by the contract.

While Instead of creating different systems and adding and correcting bugs to each, it seems reasonable to be able to set what will or not be shipped to client. I'm trying to find an elegant solution to that ... my Controllers and my Models will remain exactly the same, but my Views will change big time.

Any thoughts on how to make that work?

Upvotes: 3

Views: 365

Answers (3)

Tejo
Tejo

Reputation: 1268

Shouldn't you put this information in the database(like, wich views the user has access to) and build your menus based on this information?

This would mean that your entire menu structure will become dynamic(so this would change a lot, as i imagine your menus are static). But It'd solve your problem, i guess..

Upvotes: 0

WDRust
WDRust

Reputation: 3713

Not sure if i understood correctly. You have two different feature sets and want to join them in a single codebase capable of both? At what level they are similar?

I'd work on maintaining a single codebase for the data and logic layer (More Here), and depdending on the amount of differences on the presentation layer do one of the following:

  • Create another asp.net mvc3 project that uses my "shared" libs from other tiers
  • Create all the functionality on one single asp.net mvc3 project and then working on the routes to enable/disable certain stuff, if you want you can also do this on some configuration files, thus not requiring a specific build for each client.

Without more details i can't say much.

Upvotes: 1

Marthijn
Marthijn

Reputation: 3392

When only your views are different per configuration, maybe a solution is to create subfolders in each view folder. For example Views/Home/Config1/Index.cshtml, Views/Home/Config2/Index.cshtml, etc. By overriding the View (and PartialView) function in a controller (e.g. create a MasterController) you could automatically switch to the right subfolder in a view directory.

Upvotes: 0

Related Questions