Reputation: 1919
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?
Upvotes: 0
Views: 324
Reputation: 7926
I don't totally agree with Shay -- in case of a shared reusable area, templates can be specified as default and overruled in the main website project if needed. The TemplateHelper class should take areas in account when locating templates.
This is quite easy to fix, tho -- see my other post here
Upvotes: 1
Reputation: 4868
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.
Upvotes: 1