Intégration .NET - Guide de démarrage rapide

Ce guide a pour objectif de vous expliquer comment réaliser une intégration de base de CrowdHandler .NET dans votre application MVC.

For further customization and advanced configurations, please refer to the project's GitHub repository or NuGet documentation.

1.) Add reference to your project.

Le plus simple est d'utiliser NuGet. Recherchez le Crowdhandler.MVCSDK dans le gestionnaire de paquets NuGet, ou bien via l'interface de ligne de commande dotnet.

dotnet add package Crowdhandler.MVCSDK

2.) Apply the Crowdhandler Filter Attribute to your Controller Actions.

ExempleTicketingController.cs

using Crowdhandler.MVC5SDK;

namespace MyTicketingApp.Controllers
{
    public class TicketingController : Controller
    {
        [CrowdhandlerFilter]
        public ActionResult Index()
        {
            return View();
        }
    }
}

Définissez les modèles d'URL à ignorer en transmettant au filtre le paramètre « Exclusions » avec une expression régulière contenant les modèles que vous ne souhaitez pas voir pris en compte pour la mise en file d'attente.

Common patterns to ignore are:

  • Paths used for storing static assets and media, e.g. /static-media/*
  • URL de rappel générées par des prestataires de paiement tiers.
  • Flux JSON et RSS.

ExempleTicketingController.cs

using Crowdhandler.MVCSDK;

namespace MyTicketingApp.Controllers
{
    public class TicketingController : Controller
    {
        [CrowdhandlerFilter(Exclusions = @"^(\/contact-us.*)|((?!.*\?).*(\.(avi|css|eot|gif|ICO|jpg|jpeg|js|json|mov|mp4|mpeg|mpg|og[g|v]|pdf|png|svg|ttf|txt|wmv|woff|woff2|xml)))$")]
        public ActionResult Index()
        {
            return View();
        }
    }
}

3.) Inject CrowdHandler Configuration.

* Public and Private keys can be found in the Account → API section of the CrowdHandler administration control panel.

via app.config ou web.config

<appSettings>
    <add key="CROWDHANDLER_PUBLIC_KEY" value="YOUR_PUBLIC_KEY"/>
    <add key="CROWDHANDLER_PRIVATE_KEY" value="YOUR_PRIVATE_KEY"/>
</appSettings>

Il est également possible de les injecter directement dans le filtre.

using Crowdhandler.MVC5SDK;

namespace MyTicketingApp.Controllers
{
    public class TicketingController : Controller
    {
        [CrowdhandlerFilter(PrivateApiKey = "YOUR_PRIVATE_KEY", PublicApiKey = "YOUR_PUBLIC_KEY")]
        public ActionResult Index()
        {
            return View();
        }
    }
}

* A full list of configurables and their default settings can be found in section 2b of the NuGet documentation.

https://www.nuget.org/packages/Crowdhandler.MVCSDK/

4.) Install CrowdHandler JavaScript Integration

Pourquoi dois-je faire cela si j'intègre CrowdHandler côté serveur ?

To ensure that the integration executes as quickly as possible, functionality not considered mission-critical is offloaded to the client side via our JavaScript Integration.

Si cette fonctionnalité n'est pas essentielle à la mission, puis-je sauter cette étape ?

Theoretically yes, but practically we recommend against it. Installing the JavaScript integration enables features such as page performance tracking and smart session keep alive.

Le premier est indispensable au bon fonctionnement de notre fonctionnalité d'ajustement automatique et permet en outre de suivre les performances de votre application en situation de charge.

The latter synchronizes session information between the client side and CrowdHandler's backend, preventing recently active users that have spent longer than the configured CrowdHandler session time from being sent to CrowdHandler's session validator for revalidation needlessly.

How do I install the JavaScript integration

The JavaScript can be installed via Google Tag Manager, by directly including it in the head of your master template or in any other way that is convenient to you.

You can find instructions on installing our JavaScript integration.

5.) Change integration type to .NET in CrowdHandler control panel.

La sélection du déploiement peut s'effectuer depuis l'écran des domaines.

6.) What Now?

Once you have completed the .NET integration steps we recommend checking out our getting started guide which will help familiarize you with creating and configuring waiting rooms from within the CrowdHandler control panel.