We have moved!
You are currently looking at documentation for Umbraco 8 and older versions.
Go to docs.umbraco.com for documentation for Umbraco 9 and newer versions.
The ContentService acts as a "gateway" to Umbraco data for operations which are related to Content.
All samples in this document will require references to the following dll:
All samples in this document will require the following using statements:
using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Services;
Getting the service
If you wish to use use the content service in a class that inherits from one of the Umbraco base classes (eg.
UmbracoAuthorizedApiController), you can access the content service through a local
IContentService contentService = Services.ContentService;
In Razor views, you can access the content service through the
IContentService contentService = ApplicationContext.Services.ContentService;
If neither a
Services property or a
ApplicationContext property is available, you can also reference the
ApplicationContext class directly and using the static
IContentService contentService = ApplicationContext.Current.Services.ContentService;