I am experimenting with Azure Notification Bus, and my goal is to have a WebApi service sending push notifications upon specific events triggered by controller actions.
I was wondering where would be the correct place to instantiate the NotificationHubClient
object.
I assume it could be either in the controller (right before sending the notification), or instead it could be globally initialized (like in the App_Start) and re-used in the controllers.
In this example tutorial, the NotificationHubClient
is instantiated in the controller:
public RegisterController()
{
var cn = "<FULL_SAS_CONNECTION_STRING>";
hubClient = NotificationHubClient(cn, "<NOTIFICATION_HUB_NAME>");
}
What would be the preferred way?