Impworks
Impworks

Reputation: 2818

Two ASP.NET MVC websites in one: shared logics, different designs

What is the best approach to keeping two separate sets of views in one application?

I need to create two websites which have different frontend layouts, but have almost identical code base (admin area, controller logic, etc). There are supposed to be two build configurations that decide which layout to use.

Upvotes: 0

Views: 50

Answers (2)

Chris Pratt
Chris Pratt

Reputation: 239270

If the only difference is which layout will be used. You could set this as an AppSetting in your Web.config and then create different configurations for each site. In Views\_ViewStart.cshtml you can pull the layout path from ConfigurationManager.AppSettings. When publishing, you simply choose which configuration you want to publish, and then use the configuration-specific web.config transform to change the AppSetting appropriately.

Upvotes: 0

e4rthdog
e4rthdog

Reputation: 5223

Take a look into the concept of using Areas for organizing your project

With Areas you can blend your logic and separate it as you wish. Areas have their own front end by having a separate Views directory (although you can have multiple Areas use a common layout).

Upvotes: 2

Related Questions