Notifiers represent configuration for notifications.

Currently you can't use notifiers directly in configuration logic, instead use them in custom code (Code Behind).

Notifier properties






Name of the Notifier. Used to create Notifiers enumerator. Then specified settings could be accessed using this enumerator (see example below).



There are three types available but only Email type is fully functional.



Email server address.



Email server port.


Settings.From Email

Address that would be placed in From property for sent emails. Also used as a login to mail server.



Password to access email server.


Settings.From Name

Name that would be placed in From property for sent emails.

Configuration is stored in web.notifiers.config file on server side.

Using Notifiers

There are two main scenarios to use notifications.

1) Create notifications in a place of an event. Here is an example for email notification for newly created Orders object.

This scenario is best if there are minor quantity of notification recipients or notifications because the process of notification sending takes some time and slows down the application.

If you have large amount of notifications it is better to go with the second scenario. See Dependency Injection for details on constructor parameters.

   public sealed class OrdersRepository : CodeBehind.CodeBehindOrdersRepository, IOrdersRepository


       private readonly INotifierManager _notifierManager;

       /// <summary>


       /// </summary>

       public OrdersRepository(

             //--  custom dependencies

           INotifierManager notifierManager,

           //-- /custom dependencies

           IApiDbContext context, IApiReadOnlyDbContext readOnlyContext)

                   : base(context, readOnlyContext)


           _notifierManager = notifierManager;


       public override Orders Create(Orders obj)


           return base.Create(obj);

           var mailSettings = new EmailNotifierSettings();

           mailSettings.CcList.Add(new MailAddress(""));

           mailSettings.IsMessageHtml = false;

           mailSettings.Subject = "Mail subject";

           mailSettings.Message = $"Hello World!";

           _notifierManager.Notify(Notifiers.Default, mailSettings); // Notifiers is a enumerator with configuration names from configuration utility




2) Use change tracking class to send notifications asynchronously. This option is better for massive notification sending but takes more time to implement.

Here is an example:

   public class NotificationChangeTracker : IChangeTracker


       private readonly ICurrentActionService _currentActionService;

       private readonly IAppSettingsService _appSettingsService;

       private readonly INotifierManager _notifierManager;

       private IReadOnlyCollection<IObjectChange> _changes;

       /// <inheritdoc />

       public NotificationChangeTracker(

           ICurrentActionService currentActionService,

           IAppSettingsService appSettingsService,

           INotifierManager notifierManager)


           _currentActionService = currentActionService;

           _appSettingsService = appSettingsService;

           _notifierManager = notifierManager;


       public bool BeforeSaveAction(IReadOnlyCollection<IObjectChange> changes)


           _changes = changes; // Save any changes made to data objects if you need data change driven notifications.

           return true;


       public void AfterSaveAction()


           // you can analyze _changes collection and make corresponding notifications.

           throw new NotImplementedException();


       public int Rank => 0;


Don't forget to register change tracker in DependencyInjectionConfig.Custom.cs (see Dependency Injection for details):

registrator.PerRequest<IChangeTracker, NotificationChangeTracker>("NotificationChangeTracker");

Created with the Personal Edition of HelpNDoc: Write EPub books for the iPad