ASP.NET Core
ASP.NET Core in the .NET SDK.
| Symbol | Kind | Summary |
|---|---|---|
NexusAspNetCoreExtensions | static class | Wires the Nexus middleware into an ASP.NET Core application. |
NexusAspNetCoreOptions | class | How the middleware reads a request. |
NexusMiddleware | class | Binds each request's identity, route and device into the ambient telemetry context, and reports unhandled exceptions. |
NexusAspNetCoreExtensions
static class Inverge.Nexus.AspNetCorestatic class Inverge.Nexus.AspNetCore.NexusAspNetCoreExtensionsWires the Nexus middleware into an ASP.NET Core application.
AddNexusAspNetCore()
extension methodstatic IServiceCollection AddNexusAspNetCore(IServiceCollection services, Action<NexusAspNetCoreOptions>? configure = null)Configures how the middleware reads a request.
Parameters
Prop
Type
Returns IServiceCollection
UseNexus()
extension methodstatic 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.AspNetCoreclass Inverge.Nexus.AspNetCore.NexusAspNetCoreOptionsHow the middleware reads a request.
NexusAspNetCoreOptions
constructornew NexusAspNetCoreOptions()CaptureUnhandledExceptions
propertybool 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
propertystring 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
propertystring DeviceKeyHeader { get; set; }Header carrying the device key.
IgnoredPathPrefixes
propertyIList<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
propertybool 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
propertystring RequestEventName { get; set; }The event name used when TrackRequests is on.
ResolveDistinctId
propertyFunc<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
propertyFunc<HttpContext, IReadOnlyDictionary<string, object?>?>? ResolveProperties { get; set; }Extra properties attached to every event captured during the request.
ResolveSessionKey
propertyFunc<HttpContext, string?>? ResolveSessionKey { get; set; }Reads the session key. Defaults to SessionKeyHeader.
SessionKeyHeader
propertystring SessionKeyHeader { get; set; }Header carrying the journey session key.
TrackRequests
propertybool 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.AspNetCoreclass Inverge.Nexus.AspNetCore.NexusMiddlewareBinds 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
constructornew NexusMiddleware(RequestDelegate next, INexusClient client, IOptions<NexusAspNetCoreOptions> options)Creates the middleware.
Parameters
Prop
Type
InvokeAsync()
methodTask InvokeAsync(HttpContext context)Runs the middleware.
Parameters
Prop
Type
