public async Task <IActionResult> GetByCredentialId([GetterParameter][FromRoute] string credentialId) { if (string.IsNullOrEmpty(credentialId)) { throw new ArgumentNullException(nameof(credentialId)); } UserAgentOverview agent = RequestInfoService.UserAgent; Session session = await SessionStore.Get(credentialId, agent.DeviceClass, agent.DeviceName, agent.AgentName, agent.AgentVersion); if (session == null) { return(NotFound()); } return(Element <Session>(session)); }
public RequestInfoService( IHttpContextAccessor httpContextAccessor, IUserAgentParsingService userAgentParsingService) { _httpContext = httpContextAccessor?.HttpContext ?? throw new ArgumentNullException(nameof(httpContextAccessor)); _userAgentParsingService = userAgentParsingService ?? throw new ArgumentNullException(nameof(userAgentParsingService)); if (_httpContext != null) { _requestedUrl = _httpContext.Request.Path; _requestQueryString = _httpContext.Request.QueryString.HasValue ? _httpContext.Request.QueryString.Value : null; string body = GetRequestBody(_httpContext.Request).Result; _requestBody = string.IsNullOrEmpty(body) ? null : body; _requestedVerb = _httpContext.Request.Method; _acceptLanguageHeader = _httpContext.Request.Headers["Accept-Language"].ToString(); _userAgentHeader = _httpContext.Request.Headers["User-Agent"].ToString(); _userAgent = _userAgentParsingService.Parse(_userAgentHeader); _requestId = _httpContext.TraceIdentifier; _requestStartDateUtc = DateTime.UtcNow; _idProcess = Process.GetCurrentProcess().Id; _requestStartUnixTimestamp = ((DateTimeOffset)_requestStartDateUtc).ToUnixTimeSeconds(); if (_httpContext.Connection.RemoteIpAddress != null) { _ipRemote = _httpContext.Connection.RemoteIpAddress.MapToIPv4().ToString(); } else { _ipRemote = Constants.UNKNOWN_IP; } } }