09 Sep 2019
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
Thanks to Ronald for sharing this tip in the slack group.
You can join the Umbraco Discord by visiting https://discord.gg/umbraco