The purpose of this guide is to outline how to perform a basic CrowdHandler .NET integration in your MVC application. 

For further customisation and advanced configurations please refer to the project's Nuget Documentation.

1.) Add reference to your project.

This is easiest done using NuGet, find the Crowdhandler.MVCSDK package in the NuGet package manager, or alternatively, via the dotnet CLI.

dotnet add package Crowdhandler.MVCSDK

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

ExampleTicketingController.cs

using Crowdhandler.MVC5SDK;

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

Set URL patterns to be ignored by passing the "Exclusions" parameter to the filter with a regular expression containing the patterns you would like to not be considered for queueing.

Common patterns to ignore are:

* Paths used for storing static assets and media i.e. /static-media/*
* Callback URLs made by third party payment providers.
* JSON and RSS feeds.

ExampleTicketingController.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 or web.config

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

Alternatively, they can be injected directly into the filter.

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

Why do I need to do this if I'm integrating CrowdHandler server-side?

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

If the functionality isn't mission critical can I skip this step?

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

The former is a requirement for our autotune feature to work correctly in addition to providing visibility into how your application is performing under load.

The latter synchronises session information between the clientside and CrowdHandler's backend preventing recently active user's 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 how to install our Javascript integration here.

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

Deployment selection can be done from the domains screen.

6.) What Now?

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