Copied to clipboard

Flag this post as spam?

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


  • Tobbe 81 posts 387 karma points c-trib
    Feb 16, 2015 @ 15:11
    Tobbe
    0

    Set all razor views to inherit from Umbraco.Web.Mvc.UmbracoTemplatePage

    Im trying to make all razor views inherit from Umbraco.Web.Mvc.UmbracoTemplatePage. So that I dont have to have @inherits Umbraco.Web.Mvc.UmbracoTemplatePage at the top of every page.

    Adding Umbraco.Web.Mvc.UmbracoTemplatePage to pageBaseType in the web.config in the Views folder kind of works..

    Problem is that I want Model.Content to be static, but it becomes dynamic so I dont get any intellisence :( Is there a way to make it static (as it would be if I've added Umbraco.Web.Mvc.UmbracoTemplatePage at the top of the razor file)?

    <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="Umbraco.Web.Mvc.UmbracoTemplatePage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="Umbraco.Web" />
        <add namespace="Umbraco.Core" />
        <add namespace="Umbraco.Core.Models" />
        <add namespace="Umbraco.Web.Mvc" />
        <add namespace="Microsoft.Web.Helpers" />
        <add namespace="umbraco" />
        <add namespace="Examine" />
      </namespaces>
    </pages>
    

  • Tobbe 81 posts 387 karma points c-trib
    Feb 20, 2015 @ 13:49
    Tobbe
    0

    shameful bump.

  • Richard Terris 273 posts 715 karma points
    Mar 02, 2015 @ 21:18
    Richard Terris
    0

    If you have Umbraco.Web.Mvc.UmbracoTemplatePage at the top of your _Layout View, then any views which inherit from this will inherit from UmbracoTemplatePage.

    That's how I'd do it.

    Also, doing it this way means you can override the model on any specific view just by adding the @inherits on that/those view(s) in case your model is different on some pages.

  • Sundar 1 post 71 karma points
    Sep 28, 2016 @ 02:25
    Sundar
    0

    Close your view and re-open to get the intellisence. This is working fine in MVC 4

Please Sign in or register to post replies

Write your reply to:

Draft