views:

24

answers:

1

I defined a few display templates for classes and they work well when I put them in views/shared/DisplayTemplates. However after I move them into an area, looks like ASP.NET MVC won't look inside Area to find the templates.

How to reference the DisplayTemplates defined in an Area from main project? Is that a good practise?

A: 

I don't think you can reference display templates that exist inside an area from the main project or a different area.

This is very logical and I think you should follow this constraint and not try to workaround it. Think of an area as a separated logical part of your application - it should have all its resources inside the area. However, when you have a resource like a master layout or a logo image that should be used from other areas as well, then this resource should be placed on the main project folders and not in specific areas to make it available to all.

Shay Friedman
The reason why I wish to reference a templates inside an area is because I wish to extend the main application by simply adding some reusable area, the data type, the display template of such data type are all inside an area. I would wish the "displayfor" for such new data type (which inherit from a class in main application) automatically pick up its own template in the area. I think this should be a pretty valid user scenario.
Robert Mao