10

I'm working with Tridion 2011 SP1 and Razor templating but have an issue with creating pages and inserting content through the User Interface 2012. It appears when I try this that my Razor helpers, namespaces and assemblies listed in the Tridion.ContentManager.config file don't get included.

I tried adding the references to the helpers directly in the razor templates and everything works fine but I would prefer to not have to do this in every Razor Template.

When I try creating a page through the UI I get the following Razor error:

TemplateCompileException: CS0103: The name 'GetBreadcrumbStatus' does not exist 
in the current context Line 64 Column 21: if(GetBreadcrumbStatus())

My Tridion.ContentManager.config file contains the following for the Razor Mediator:

<razor.mediator cacheTime="600" extractBinaries="true">
 <namespaces>
  <add namespace="Tridion.Extensions.Mediators.Razor.Models" /> 
  <add namespace="System.Linq" />
 </namespaces>
 <imports>
  <add import="C:\Program Files (x86)\Tridion\Razor Mediator\Helpers\GeneralHelper.cshtml" />
 </imports>
</razor.mediator>

Any ideas as to why the UI doesn't include the helpers and namespaces unless there referenced directly in the Razor templates?

Thanks in advance.

1 Answers1

9

Some background on the Session Preview mechanism

The new UI uses a special type of publisher for its Session Preview mechanism, which optimizes the publishing process to get the "near real time" behavior that people expect in such an environment. The optimized publisher accomplishes this by skipping certain steps, one of which is reducing the resolving process (so fewer items get publishes) and not invoking custom resolvers.

On your problem

Are your Razor templates invoked at all when you create the new page?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Thanks for the explanation Puf. It appears the Razor templates are invoked, it just can't find the helpers and assemblies that are used in them as they havn't been included. Looks like I might have to reference the assemblies and helpers in every razor template as opposed to in the Tridion config file. Thanks. –  Aug 02 '12 at 11:30
  • OK, that's indeed how I also ready your initial report. I don't really get how that can be, since (AFAIK) those imports are handled by the Razor mediator itself. Since that gets invoked, why would it not process the imports? Weird. :-/ – Frank van Puffelen Aug 02 '12 at 15:07