Copied to clipboard

Flag this post as spam?

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


  • Tom 691 posts 908 karma points
    Mar 05, 2015 @ 00:06
    Tom
    0

    Custom Razor Page Base Type

    Hi Just wondering if it was possible to inherit from umbraco.MacroEngines.DynamicNodeContext to have a custom pageBaseType for razor views?

    I've tried:

    public abstract class MyViewPage : umbraco.MacroEngines.DynamicNodeContext
        {
            public MyHelper My { get; set; }
    public override void InitHelpers() { base.InitHelpers(); My= new MyHelper<object>(base.ViewContext, this);
    } }
     <system.web.webPages.razor>
        <host factoryType="umbraco.MacroEngines.RazorUmbracoFactory, umbraco.MacroEngines" />
        <pages pageBaseType="umbraco.MacroEngines.DynamicNodeContext">
          <namespaces>
            <add namespace="Microsoft.Web.Helpers" />
            <add namespace="umbraco" />
            <add namespace="Examine" />
          </namespaces>
        </pages>
      </system.web.webPages.razor>

    The base class doesn't contain a viewcontext to hook in to. I was wondering what was required to hook this up?

  • Asbjørn 74 posts 178 karma points c-trib
    Mar 05, 2015 @ 17:35
    Asbjørn
    0

    Which Umbraco version are you using? umbraco.MacroEngines.DynamicNodeContext is only used for the old Razor Macros, which are deprecated as of v6.

    If you're using full MVC views (in the Views folder), you'd probably want to inherit from UmbracoViewPage or UmbracoTemplatePage.

    What are you trying to achieve?

    Asbjørn

Please Sign in or register to post replies

Write your reply to:

Draft