In the example below, a new page is programmatically created using the content service. It is assumed that there are two document types, namely people and person. In this case, a new person is added underneath the people page.
The ContentService acts as a "gateway" to Umbraco data for operations which are related to Content.
Browse the v9 API documentation for ContentService.
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
All samples in this document will require references to the following dll:
Umbraco.Core.dll
All samples in this document will require the following using statements:
For Razor views:
If you wish to use the content service in a class, you need to use Dependency Injection (DI) in your constructor:
In Razor views, you can access the content service through the @inject
directive: