In ASP.NET MVC (not Core) we were able to create a class that derives from WebViewPage and set it as the base class for all razor views (by setting the value of the pageBaseType