Using Visual Studio 2012 I am able to edit Razor TBBs by opening and saving them back via webdav. The problem is that if there is a Razor syntax error, it seems like they are saved OK, but actually they are not - there is no feedback of the error that you would normally get when saving them using the Tridion GUI. Is it possible to get Visual Studio to show this error, or (even better) get Visual Studio do the compilation/error checking that Tridion does before saving?

  • Saving any template type works like this, all the way back to VBScript. Saving via webdav seems to work (save) but if there is an error a new version is not created. I think you will have to look for a different approach than webdav to ever see error messages. Jul 31, 2013 at 16:06

3 Answers 3


I developed Visual Studio 2010 Extension (might be working in 2012) for synchronization Visual Studio *.cshtml files with Tridion TBBs via CoreService


The main idea how to make razor mediator files editable is next:

  1. Add next web.config to 'fake' ASP.NET MVC application

    <?xml version="1.0" encoding="utf-8"?>
        <compilation debug="true" targetFramework="4.0">
            <add assembly="Tridion.Extensions.Mediators.Razor, Version=, Culture=neutral, PublicKeyToken=5eeceedb34d9dfd7" />
            <add assembly="Tridion.Common, Version=, Culture=neutral, PublicKeyToken=349a39f202fa9b53" />
            <add assembly="Tridion.ContentManager.Templating, Version=, Culture=neutral, PublicKeyToken=360aac4d3354074b" />
  2. Add declaration to the top of razor file

    @inherits Tridion.Extensions.Mediators.Razor.TridionRazorTemplate

Please read document for details https://drive.google.com/folderview?id=0B6hZ-cambftrV25ZLU5QTnJWSmM&usp=sharing#list


  • Thanks for sharing this. It's great. Would you consider putting the source into Source Control? Jan 4, 2014 at 8:23

I like the idea of capturing the error in Visual Studio. One possible approach might be to execute the relevant mediator code in a build step or from a VS extension. I'd start with the Compile method at https://code.google.com/p/razor-mediator-4-tridion/source/browse/trunk/Tridion.Extensions.Mediators.RazorMediator/Tridion.Extensions.Mediators.RazorMediator/Engine/Compiler.cs

You may be able to get this to work directly, but if not, I think it would be a great enhancement for the mediator if we could get it to support this approach. It's probably much easier if you are developing on the machine where Tridion is installed. To support off-the-box work, we might need some sort of service.


Here is in my blog explained how to debug Razor Mediator .cshtml files in Visual Studio.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.