MacrosService will be removed in the next version.

Defines the MacroService, which is an access to operations involving IMacro.

Browse the API documentation for IMacroService interface.

  • Namespace: Umbraco.Cms.Core.Services

  • Assembly: Umbraco.Core.dll

All samples in this document will require references to the following dll:

  • Umbraco.Core.dll

using Umbraco.Cms.Core.Services;

For Razor views:

@using Umbraco.Cms.Core.Services

Getting the service

Dependency Injection

If you wish to use the macro service in a class, you need to specify the IMacroService interface in your constructor:

public class MyClass
    private IMacroService _macroService;

    public MyClass(IMacroService macroService)
        _macroService = macroService;

In Razor views, you can access the macro service through the @inject directive:

@inject IMacroService MacroService

Last updated