Crowdhandler.MVCSDK 1.0.5

.NET 5.0 .NET Framework 4.5
dotnet add package Crowdhandler.MVCSDK --version 1.0.5
NuGet\Install-Package Crowdhandler.MVCSDK -Version 1.0.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Crowdhandler.MVCSDK" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Crowdhandler.MVCSDK --version 1.0.5
#r "nuget: Crowdhandler.MVCSDK, 1.0.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Crowdhandler.MVCSDK as a Cake Addin
#addin nuget:?package=Crowdhandler.MVCSDK&version=1.0.5

// Install Crowdhandler.MVCSDK as a Cake Tool
#tool nuget:?package=Crowdhandler.MVCSDK&version=1.0.5

Crowdhandler MVC .NET SDK

Protect your .NET MVC Applications with Crowdhandler.

Nuget Package [Github](<RepositoryUrl>https://github.com/Crowdhandler/crowdhandler-dotnet-integration</RepositoryUrl>)

Getting Started

1) Add Reference to your project

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

dotnet add package Crowdhandler.MVCSDK

2a) Add required Crowdhandler configuration options

There are two different recommended ways of doing this.

app/web.config

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

Alternatively configuration options can be injected into the CrowdHandler Filter Attribute (step 3).

ExampleTicketingController.cs

  [CrowdhandlerFilter(PublicApiKey = "YOUR_PUBLIC_KEY", PrivateApiKey = "YOUR_PRIVATE_KEY")]

Your API keys can found in your Crowdhandler dashboard. Click here for more information

2b) Full CrowdHandler configuration options

app/web.config options:

Value Description Required Type
CROWDHANDLER_PUBLIC_KEY Your Crowdhandler public API key. Yes String
CROWDHANDLER_PRIVATE_KEY Your Crowdhandler private API key. Yes String
CROWDHANDLER_API_ENDPOINT The Crowdhandler API URL. Default: https://api.crowdhandler.com No String
CROWDHANDLER_WR_ENDPOINT Your Crowdhandler waiting room URL. Default: https://wait.crowdhandler.com No String
CROWDHANDLER_EXCLUSIONS_REGEX Regex pattern for URLs that should not be sent to the waiting room. Default: @"^((?!.*\?).*(\.(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)))$" No String
CROWDHANDLER_API_REQUEST_TIMEOUT How many seconds to wait for the Crowdhandler API to respond before failing. Default: 3 No String
CROWDHANDLER_ROOM_CACHE_TIME How many seconds to cache your Crowdhandler room configuration for. Set the value to 0 to never cache. Default: 60 No String
CROWDHANDLER_SAFETYNET_SLUG If failTrust is set to false, this waiting room slug will be used as the safety net room No String

CrowdHandler Filter Attribute options:

Value Description Required Type
PublicApiKey Your Crowdhandler public API key. Yes String
PrivateApiKey Your Crowdhandler private API key. Yes String
ApiEndpoint The Crowdhandler API URL. Default: https://api.crowdhandler.com No String
WaitingRoomEndpoint Your Crowdhandler waiting room URL. Default: https://wait.crowdhandler.com No String
Exclusions Regex pattern for URLs that should not be sent to the waiting room. Default: @"^((?!.*\?).*(\.(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)))$" No String
APIRequestTimeout How many seconds to wait for the Crowdhandler API to respond before failing. Default: 3 No String
RoomCacheTTL How many seconds to cache your Crowdhandler room configuration for. Set the value to 0 to never cache. Default: 60 No String
FailTrust If true, users that fail to check-in with CrowdHandler's API will be trusted. Read more about Trust on Fail - https://www.crowdhandler.com/docs/80000984411-trust-on-fail. Default: true No Boolean
SafetyNetSlug If failTrust is set to false, this waiting room slug will be used as the safety net room. No String
DebugMode For local development. Default: false No Boolean
GateKeeperType If set, this Class of GateKeeper will be used instead of the default when validating users. Used to implement custom behavior in the GateKeeper validation process. Default: null No Type implementing IGateKeeper

* FailTrust can only be set via Filter Attribute ** DebugMode can only be set via Filter Attribute *** GateKeeperType can only be set via Filter Attribute

3) Apply the Crowdhandler Filter Attribute to your Controller Actions

ExampleTicketingController.cs

using Crowdhandler.MVCSDK;

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

Custom URL exclusion pattern example:

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();
        }
    }
}

4) Advanced Customisation

If you need finer control from the Action Filter, you can extend the CrowdhandlerFilterAttribute class, implement your own logic, and then execute it. For example:

MyCustomLogicFilterAttribute.cs

public class MyCustomLogicFilterAttribute : CrowdhandlerFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        var url = filterContext.HttpContext.Request.Url;

        // do not attempt to validate the json events feed
        if (url.AbsolutePath.StartsWith("/events/feed"))
        {
            // return to controller
            return;
        }

        // Run validation
        base.OnActionExecuting(filterContext);
    }
}

Then update your controller to use this new Filter Attribute

ExampleTicketingController.cs

public class TicketingController : Controller
{
    [MyCustomLogicFilter]
    public ActionResult Index()
    {
        return View();
    }
}

Extend/Override the IGateKeeper class

By default the Crowdhandler room configuration is fetched via the API and then cached in memory for 1 minute. If you would like to bypass this and keep static copy of the Configuation locally, you can do this by extending/implementing your own IGateKeeper class, and passing it's type to the GatekeeperType property of the CrowdhandlerFilterAttribute. For example:

MyCustomGateKeeper.cs

using Crowdhandler.NETsdk;
using Crowdhandler.NETsdk.JSONTypes;
using Newtonsoft.Json;

public class MyCustomGateKeeper : GateKeeper
{
    public override List<RoomConfig> getRoomConfig()
    {
        return JsonConvert.DeserializeObject<List<RoomConfig>>(System.IO.File.ReadAllText(@"path_to_roomconfig.json"));
    }
}

ExampleTicketingController.cs

public class TicketingController : Controller
{
    [CrowdhandlerFilter(GatekeeperType = typeof(MyCustomGateKeeper))]
    public ActionResult Index()
    {
        return View();
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.5 159 2/9/2023
1.0.4 156 2/7/2023
1.0.3 174 2/1/2023
1.0.2 225 12/9/2022
1.0.1 219 12/6/2022
1.0.0 241 10/17/2022