Providing MVC Shared Folder Structure
I'm working on a project and I would like to be able to place a number of views within the shar开发者_Go百科ed folder. However when these are all created (through a generation process) i begin to feel "custer&^%$ fobic" due to having X * N partial views within the shared folder and am looking for a better organizational model.
Is it possible to just create a folder structure in the Shared folders and "Hope" MVC wires them up correctly or do I have to do something else.
Ex. Folder structure I have
...
Shared
Product1DropdownList.ascx
Product2DropdownList.ascx
Product3DropdownList.ascx
Product1Search.ascx
Product2Search.ascx
Product3Search.ascx
...
Folder Structure I would like
...
Shared
Product
Product1DropdownList.ascx
Product1Search.ascx
Product2
Product2DropdownList.ascx
Product2Search.ascx
Product3
Product3DropdownList.ascx
Product3Search.ascx
...
This sounds like a case for a simple ViewEngine over-ride.
In your derived ViewEngine, you can set rules, subdirectorties to search etc etc to instruct MVC how to find the view .....
There are quite a few examples of this approach around the web, but no "definitive" code since the usage can be quite dynamic, but I suggest you refer to:
Chris Pietschmann:Implement Theme Folders using a Custom ViewEngine
for ideas and inspiration.
精彩评论