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"
For F# scripts that support #r syntax, copy this into the source code to reference the package.
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.
Dependencies
-
.NETCoreApp 2.0
- Microsoft.AspNetCore (>= 2.0.0)
- Microsoft.IdentityModel.Tokens (>= 5.1.4)
Used By
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 | 991 | 1/16/2018 |