0

I have EditorTemplates directory under ~\Views\Items.

Everything works fine on local system.

I published the project on server, configured IIS and Started the application. It was rendering:

System.Data.Entity.DynamicProxies.Items.....

for 1:m views, where I was using EditorTemplates. I spent couple of hours searching and found solutions like: "it is due to lazy loading, turn it off by using .ToList()", "don't use nested entities in Views", "refactor your models and use ViewModels" etc. Some of those were not applicable, some did not work, and some required a lot more work than I anticipated: refactoring the ready-to-launch application.

Later I realized that the issue was with Views on deployment server missing the EditorTemplates directories, while the folder exists locally and source-control. The issue was fixed by manually copying EditorTemplates directory under ~\Views\Items.

  • Is there a reason why publish machinery ignores EditorTemplates directories?
  • Any way to configure it so it does not ignore those on publishing the application?
Annie
  • 3,090
  • 9
  • 36
  • 74
  • Everything under `~/Views` should be copied as-is in the published copy of your site. How are you publishing? Also, stab in the dark, but make sure the Build Action for the views is set to "Content" (in File Properties pane). You may be tempted to also set them to copy to output directory, but that actually copies the files to the bin folder. That's not what you want. – Chris Pratt Dec 02 '14 at 18:16
  • @ChrisPratt, thanks. Actually, all `.cshtml` files under `~\Views` are set to `Do not copy`, the default MVC app action. I am publishing via FileSystem option. It could be a bug in publishing functionality or EditorTempates are not meant to be copied in production environment? – Annie Dec 02 '14 at 18:25
  • No, editor templates are indeed meant to be copied. They have to be because views aren't utilized until runtime. If this is a bug, it would be a pretty major one, and there'd be quite a herd of complaints, I'm sure. There's probably just something misconfigured somewhere in your solution, but without being there with you looking at it on your computer it might be hard to give you any definitive answers. Since you're using source control, have you tried publishing from a different machine to see what happens? – Chris Pratt Dec 02 '14 at 18:39
  • Yes, same result, if I publish on in a local folder under c: drive. – Annie Dec 02 '14 at 20:05

0 Answers0