This article has not yet been verified against Umbraco 8.
The concepts and code examples might not work if you are running Umbraco 8.0 or a later version. If you are using Umbraco 7, this article is perfect for you!
You are more than welcome to report any issues found on the Documentation Issue Tracker.
Executing an Umbraco request
During the Umbraco request execution, an MVC Action is called which executes a Razor view to render content to the end-user
Using the Model
Whenever a content item is rendered on the front-end, it is based on a model of type
This model contains all of the information about the content item associated with the current request.
If you are working in a custom MVC Controller's action, a model of type
RenderModel will be provided in the Action's method parameters.
This model contains an instance of
IPublishedContent which you can use.
When you are working in a View of type
UmbracoTemplatePage (which is the default view type), the Model provided to that view
will also be
RenderModel which exposes
IPublishedContent. For example, to render the current content model's name you could do:
All Umbraco view page types inherit from
UmbracoViewPage<TModel>. A neat trick is that if you want your view Model to be
you can change your view type to
UmbracoViewPage<IPublishedContent> and the view will still render without issue even though the controller
is passing it a model of type RenderModel.
IPublishedContent is the standard model used for all published content, media and members in Umbraco. It is a strongly typed model and is very flexible.
There's also a dynamic representation of
DynamicPublishedContent. This is available on
UmbracoTemplatePage as the property
Working with dynamics is simpler in some cases especially with regards to referencing property data. For example, to output your custom property 'markDown', you could do the following:
However, a dynamic object does not provide any intellisense and is compiled at runtime.
UmbracoHelper is the unified way to work with published content/media on your website. Whether you are using MVC or WebForms you will be able to use UmbracoHelper to query/traverse Umbraco published data.
MembershipHelper is a general helper class for accessing ASP.NET membership data, as well as Umbraco Member data, which are stored in a format similar to Umbraco content and media.