Onots.AspNetCore.Identity.Anonymous 1.0.1

Middleware for ASP.NET Core to enable the tracking of anonymous users

Based on the initial work by Alessandro Riperi

Install-Package Onots.AspNetCore.Identity.Anonymous -Version 1.0.1
dotnet add package Onots.AspNetCore.Identity.Anonymous --version 1.0.1
<PackageReference Include="Onots.AspNetCore.Identity.Anonymous" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Onots.AspNetCore.Identity.Anonymous --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Onots.AspNetCore.Identity.Anonymous, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Onots.AspNetCore.Identity.Anonymous as a Cake Addin
#addin nuget:?package=Onots.AspNetCore.Identity.Anonymous&version=1.0.1

// Install Onots.AspNetCore.Identity.Anonymous as a Cake Tool
#tool nuget:?package=Onots.AspNetCore.Identity.Anonymous&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

AnonymousId

Middleware for ASP.NET Core to enable the tracking of anonymous users

Usage

Register without options:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    app.UseAnonymousId();
    ....
}

Register with options:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    app.UseAnonymousId(new AnonymousIdCookieOptionsBuilder()
      .SetCustomCookieName("MY_COOKIE_NAME")					// Custom cookie name
      .SetCustomCookieSecurePolicy(CookieSecurePolicy.Always)	// Requires SSL
      .SetCustomCookieTimeout(120)                 				// Custom timeout in seconds
      .SetCustomCookieDomain("www.contoso.com")    				// Custom domain
      .SetCustomCookiePath("/path")               				// Custom path
      .SetCustomHeaderName("AnonymousId"));  			 		// Custom header name
    ....
}

Get AnonymousId:

public class HomeController : Controller
{
  public ViewResult Index()
  {
      IAnonymousIdFeature feature = HttpContext.Features.Get<IAnonymousIdFeature>();
      if (feature != null)
      {
        string anonymousId = feature.AnonymousId;
      }
      ....
  }
}

License

This project is licensed under the terms of the MIT license.

AnonymousId

Middleware for ASP.NET Core to enable the tracking of anonymous users

Usage

Register without options:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    app.UseAnonymousId();
    ....
}

Register with options:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    app.UseAnonymousId(new AnonymousIdCookieOptionsBuilder()
      .SetCustomCookieName("MY_COOKIE_NAME")					// Custom cookie name
      .SetCustomCookieSecurePolicy(CookieSecurePolicy.Always)	// Requires SSL
      .SetCustomCookieTimeout(120)                 				// Custom timeout in seconds
      .SetCustomCookieDomain("www.contoso.com")    				// Custom domain
      .SetCustomCookiePath("/path")               				// Custom path
      .SetCustomHeaderName("AnonymousId"));  			 		// Custom header name
    ....
}

Get AnonymousId:

public class HomeController : Controller
{
  public ViewResult Index()
  {
      IAnonymousIdFeature feature = HttpContext.Features.Get<IAnonymousIdFeature>();
      if (feature != null)
      {
        string anonymousId = feature.AnonymousId;
      }
      ....
  }
}

License

This project is licensed under the terms of the MIT license.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.1 1,054 1/16/2018