Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David F. Hill 122 posts 242 karma points
    Jun 04, 2013 @ 00:58
    David F. Hill
    1

    Mixing Web Forms and Razor Templates in the same Umbraco instance

    Hello Umbraco Colleagues,

    I'm using v. 6.0.5 and I'd like to use BOTH Web Forms and Razor in the same Umbraco instance.

    I use Razor mostly - but have a few legacy Web Forms templates that I'd like to use side-by-side with razor.

    I do not intend to have use the same docTypes/Content nodes - some docTypes would use Web Forms templates - other docTypes would use Razor.

    Is this possible?

    (Web forms templates don't show up in the template list if defaultRenderingEngine=Mvc.)

    Any help would be appreciated. Thanks,

    David HIll

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jun 06, 2013 @ 07:06
    Sebastiaan Janssen
    0

    The way to do this is to actually leave the renderengine at Webforms and then create Razor Views in /Views with the exact same filename name as your masterpages file (of course change .master to .cshtml). Umbraco will pick the .cshtml first and use mvc to render it.

  • Funka! 398 posts 661 karma points
    Jun 07, 2013 @ 00:38
    Funka!
    0

    I've been wondering this too. It would be great if /Views could be edited though the Settings section, just like master pages.

  • David F. Hill 122 posts 242 karma points
    Jun 07, 2013 @ 03:18
    David F. Hill
    4

    Thanks much, Seb.
    This got me doing a tiny bit of experimentation.
    Here are a few things I've discovered that appear to be true (please chime in if I got something wrong):

    The "defaultRenderingEngine" setting in umbracoSettings.config determines where new templates are created.
    You can change this as needed (remember to touch Web.config to get the changes to take effect).
    "WebForms" causes templates to be created in the /masterpages folder, "Mvc" in the /Views folder.

    If "defaultRenderingEngine" setting in umbracoSettings.config is "Mvc", then BOTH .master and .cshtml files will appear as templates in the Settings section.
    They have different icons according to which type they are.
    This way, just as Funka! desires, Webforms and Mvc templates can be edited  though the Settings section.

    If you have two files of the same name (one .cshtml in /Views, another .master in /masterpages), the .cshtml will be rendered regardless of which defaultRenderingEngine is used.
    Warning - if you try and edit one (defaultRenderingEngine setting determines which), the other one will be deleted.

    Hope this helps someone.
    DfH

  • Funka! 398 posts 661 karma points
    Jun 07, 2013 @ 04:01
    Funka!
    0

    David and Sebastiaan, this is good to know. I always thought it was too bad that Templates (in the settings section) couldn't have been left alone and kept for webforms master pages, and a new Views added alongside this.

    Although the workaround mentioned here is promising in that it certainly will "work", it seems like it would be a lot nicer to have this natively supported in the admin UI without any dangers of deleting anything or requiring Visual Studio (or any other external editor I suppose) to make this work.

    Thanks for your research on this!

  • Sunshine Lewis 31 posts 140 karma points c-trib
    Jun 26, 2013 @ 18:27
    Sunshine Lewis
    0

    Thank you David! I'm new to Umbraco and your aside to "touch the web.config" was the answer to 2 hours of puzzling over why my back office was still churning out masterpages.

     

  • Shaun 248 posts 475 karma points
    Aug 21, 2013 @ 01:04
    Shaun
    0

    Cheers David. I still find it faster to work the oldschool way, so the ability to generate more masterpages after setting the site to mvc is a godsend.

Please Sign in or register to post replies

Write your reply to:

Draft