· 1 min read

How to set the default page base type to UmbracoViewPage in Umbraco

In this post I share with you what Ronald Barendse taught us about setting the pageBaseType in Umbraco to save you having to type @inherits UmbracoViewPage even with a custom model.

Last week in the umbraco slack group, one of the members Ronald Barendse shared an interesting tip.

In the web.config of Views folder, you can set the pageBaseType to be Umbraco.Web.Mvc.UmbracoViewPage

<pages pageBaseType="Umbraco.Web.Mvc.UmbracoViewPage">

This means, in your view you don't have to say it inherits from UmbracoViewPage:

@inherits UmbracoViewPage<Home>

You can just declare the model like this:

@model Home

Or this:

@model IPublishedContent

You will still be inheriting from UmbracoViewPage, without needing to declare it each time.

Although Ronald doesn't recommend changing this (especially if it's not documented/shared in your team), as it's a non-standard setup and you're more explicit just adding @inherits UmbracoViewPage to your views

Thanks to Ronald for sharing this tip in the slack group.

You can join the Umbraco Discord by visiting https://discord.gg/umbraco

Comments and reactions