Greg Gum
Greg Gum

Reputation: 37909

How can I move a view to a different project?

I have a standard MVC 5 project created from the VS Template. Now I want to move the Account related controller and views to different project so it becomes a module. (That way it can easily be include/excluded from the site.)

I have been able to put the Controller in another project and reference the project, but the account views are not located at runtime.

How do I tell the View Engine to look in the other project for the account views?

Upvotes: 3

Views: 715

Answers (1)

Greg Gum
Greg Gum

Reputation: 37909

After a lot of working with this, it seems that having views in a different DLL may not be the best pattern. First, while it can be done, it requires some extra plumbing. Second, it seems to violate the MVC pattern in that now you have two MVC patterns working side by side. What has worked for me is simply moving the Model part to a different dll. In other words, the plugin becomes a Model provider which is simply used by the Controller and then combined with the view. This is very easy to work with, requires nothing special, and yet separates the responsibilities.

Upvotes: 1

Related Questions