InvergeDocs
.NETAPI reference

ASP.NET Core

ASP.NET Core in the .NET SDK.

SymbolKindSummary
NexusAspNetCoreExtensionsstatic classWires the Nexus middleware into an ASP.NET Core application.
NexusAspNetCoreOptionsclassHow the middleware reads a request.
NexusMiddlewareclassBinds each request's identity, route and device into the ambient telemetry context, and reports unhandled exceptions.

NexusAspNetCoreExtensions

static class Inverge.Nexus.AspNetCore
static class Inverge.Nexus.AspNetCore.NexusAspNetCoreExtensions

Wires the Nexus middleware into an ASP.NET Core application.

AddNexusAspNetCore()

extension method
static IServiceCollection AddNexusAspNetCore(IServiceCollection services, Action<NexusAspNetCoreOptions>? configure = null)

Configures how the middleware reads a request.

Parameters

Prop

Type

Returns IServiceCollection

UseNexus()

extension method
static IApplicationBuilder UseNexus(IApplicationBuilder app)

Adds the Nexus request middleware.

Place it after authentication, so the signed-in user is available to bind, and outside your own exception handling, so unhandled exceptions reach it.

builder.Services.AddNexus(o => o.ApiKey = "nxs_live_xxx");

var app = builder.Build();
app.UseAuthentication();
app.UseNexus();

Parameters

Prop

Type

Returns IApplicationBuilder

NexusAspNetCoreOptions

class Inverge.Nexus.AspNetCore
class Inverge.Nexus.AspNetCore.NexusAspNetCoreOptions

How the middleware reads a request.

NexusAspNetCoreOptions

constructor
new NexusAspNetCoreOptions()

CaptureUnhandledExceptions

property
bool CaptureUnhandledExceptions { get; set; }

Report unhandled exceptions to error monitoring.

The exception is reported and then rethrown unchanged, so your own error handling still runs and the response is unaffected.

CountryHeader

property
string CountryHeader { get; set; }

Header carrying the visitor's country.

Defaults to Cloudflare's CF-IPCountry. Change it to match whatever proxy actually fronts your app — behind a different CDN this header is absent and country targeting silently never matches.

DeviceKeyHeader

property
string DeviceKeyHeader { get; set; }

Header carrying the device key.

IgnoredPathPrefixes

property
IList<string> IgnoredPathPrefixes { get; }

Path prefixes the middleware ignores entirely.

Health and metrics endpoints are excluded by default: they are polled constantly, carry no user, and would otherwise dominate your telemetry.

IncludeQueryString

property
bool IncludeQueryString { get; set; }

Include the query string in the telemetry url.

Off by default. Query strings routinely carry tokens, invite codes and personal data, and telemetry is the last place that should be copied to.

RequestEventName

property
string RequestEventName { get; set; }

The event name used when TrackRequests is on.

ResolveDistinctId

property
Func<HttpContext, string?>? ResolveDistinctId { get; set; }

Reads the current person's id from the request.

Defaults to the sub / NameIdentifier claim, falling back to User.Identity.Name. Replace it when your identity lives somewhere else — a tenant-scoped id, a header from an upstream gateway.

ResolveProperties

property
Func<HttpContext, IReadOnlyDictionary<string, object?>?>? ResolveProperties { get; set; }

Extra properties attached to every event captured during the request.

ResolveSessionKey

property
Func<HttpContext, string?>? ResolveSessionKey { get; set; }

Reads the session key. Defaults to SessionKeyHeader.

SessionKeyHeader

property
string SessionKeyHeader { get; set; }

Header carrying the journey session key.

TrackRequests

property
bool TrackRequests { get; set; }

Capture one analytics event per request.

Off by default, deliberately. Events are metered, and a busy service would bill an event for every request — including health checks and static files — which is rarely what anyone wants from product analytics.

NexusMiddleware

class Inverge.Nexus.AspNetCore
class Inverge.Nexus.AspNetCore.NexusMiddleware

Binds each request's identity, route and device into the ambient telemetry context, and reports unhandled exceptions.

With this in the pipeline, nothing downstream has to pass identity to Nexus: a handler can call nexus.Track("checkout_started") and the event already carries the signed-in user, the session, the route and the request id.

NexusMiddleware

constructor
new NexusMiddleware(RequestDelegate next, INexusClient client, IOptions<NexusAspNetCoreOptions> options)

Creates the middleware.

Parameters

Prop

Type

InvokeAsync()

method
Task InvokeAsync(HttpContext context)

Runs the middleware.

Parameters

Prop

Type

On this page