It’s a static handler to be initialized once on Startup, it doesn’t have access to any per-request context itself, only if the request context was made statically available on the HTTP request worker thread that invokes the callback.
Historically this is only possible in classic ASP .NET Framework (via its HttpContext.Current
singleton) which you can access from:
var req = HostContext.AppHost.TryGetCurrentRequest();
It’s disabled in .NET Core by default due to performance, but you can opt-in to make singleton Request Context available with:
This is still only available if the callback is invoked from the HTTP Request Worker Thread. Personally I wouldn’t rely and try to access the Request Context via a singleton, I’d have Services call a generic API that passes in the base.Request
context or Session Information in from the Service.