How can I tell the viewengine to look for editortemplates in another area that is in another web project?
Asked
Active
Viewed 1,515 times
0
-
Have a look at http://stackoverflow.com/questions/5581786/can-i-add-to-the-display-editortemplates-search-paths-in-asp-net-mvc-3 It talks about how you can add paths to the search locations for view engines. – Johan van Tonder Jan 26 '12 at 09:14
2 Answers
0
Have you tried putting full path to the template (~/Areas/YourArea/Views/...) in UIHintAttribute?
Update:
I assume the code (link in the comments below) comes from one application, while the actual template resides in a different application. IMHO this just won't work. You might want to google for sharing templates between applications but I think the only valid solution is not to share a template but add extension methods to HtmlHelper and share those.

Jakub Konecki
- 45,581
- 7
- 87
- 126
-
-
I Have two different web projects so the template folders is not shared between the projects. The goal is to have a kinda dashboard project/area and I would like to use editortemplates from my main projects/area – marcus Oct 18 '10 at 05:38
-
@Marcus - so you should change your question - it's not about reusing templates from another area, but from another project! – Jakub Konecki Oct 18 '10 at 12:53
-
Well I thought it did not matter because I register the area the way you should, but maybe asp.net works differently if the area is in the same project? – marcus Oct 18 '10 at 13:04
-
@Marcus - Could you post your RegisterRoute code - how do you register a route from another application? – Jakub Konecki Oct 18 '10 at 15:57
-
This is from my global.asax http://codepaste.net/1f4r4o and this is my area registration http://codepaste.net/uca4ig – marcus Oct 18 '10 at 16:43
-
@Marcus - I assume the code comes from one application, while the actual template resides in a different application. IMHO this just won't work. You might want to google for sharing templates between applications but I think the only valid solution is not to share a template but add extension methods to HtmlHelper and share those. – Jakub Konecki Oct 18 '10 at 17:34
0
You could specify the path when including the editor template:
<%: Html.EditorFor(x => x.SomeProp, "~/areas/somearea/views/editortemplates/test.ascx") %>
Or use the UIHint attribute on the model property.

Darin Dimitrov
- 1,023,142
- 271
- 3,287
- 2,928
-
I use the UIHint attribute on my model but it seems like I must have my templates in main project? – marcus Oct 17 '10 at 10:36