Strongly Typed Models Within Umbraco

MVC stands for model, view, controller.  The idea behind this pattern is to separate your different concerns, to make testing and managing your website easier.  Historically, when developers have worked with Umbraco they have broken this paradigm.  If you have been passing in the IPublishedContent and then wiring up your properties within your views, you have in effect been muddling your HTML with your code.  

A better approach is to pass in a strongly-typed C# model into your views.  All the code and logic required to get the data needed to render page data on your page should be done in the controller level - or at a minimum - the model level.  You should avoid doing logic in your views.  Even though it is possible to do this, you are in effect breaking the MVC pattern.  One of the reasons MVC was adopted, is to make maintaining your website easier.  Every time you break the MVC approach, you will make your website that much harder to test and maintain later on.

In this section, you will learn everything you need in order for you to use MVC correctly in your website by following the correct principles of MVC

How To Get Started With Umbraco ModelsBuilder

In this tutorial, you will learn why defining your Umbraco document types in the code will make your life a lot less stressful and then how to create an Umbraco document, using the built-in ModelsBuilder.  Why Define My Document Types In Code? One [...]

Using Umbraco.ModelsBuilder.API To Create Strongly Typed Models Within Umbraco

In this tutorial, you will learn how to create strongly-typed models to use with your document types. (If you need a little more information why this is a good design approach, then I suggest you read this first). Prerequisites For Generating Models[...]

How To Use The Umbraco ModelsBuilder In Different Class Libraries Using AppData Mode

In this tutorial, you will learn how you can use the Umbraco ModelBuilder using DLL mode with multiple class libraries.  Out of the box, the ModelsBuilder, when set in DLL mode, will generate strongly-typed models within your web project (if you are [...]

How To Build An Umbraco 7 Document Types In Visual Studio - USiteBuilder Explained

When you start building a new enterprise level project, you want to be able to do things like storing your data-types in source control, unit testing your code and use features like continuous integration to automatically deploy your code. Creatin[...]

How To Use UmbracoMapper To Implement Strongly Typed Models in Umbraco 7

This article is a follow-up of, How To Build An Umbraco 7 Document Types In Visual Studio – USiteBuilder Explained . One of the aims of MVC is to be able to separate your presentation logic from your business logic.  Being able to define document typ[...]

How To Get An IPublishedContent from a Uid In Umbraco

When working with document types and properties within Umbraco 99% of the time you will be dealing with IPublishedContent and ids.  If you use the Model Builder and you work with properties like a content picker, multi-node tree picker, nest content,[...]

Homepage Learn Umbraco CMS Umbraco Developers Guide Strongly Typed Models Within Umbraco
Back to top