示例#1
0
        private string TryLookupForwardHeader(HttpRequest httpRequest, LogEventInfo logEvent)
        {
            var headerName = ForwardedForHeader.Render(logEvent);

            if (httpRequest.Headers?.ContainsKey(headerName) == true)
            {
                var forwardedHeaders = httpRequest.Headers.GetCommaSeparatedValues(headerName);
                if (forwardedHeaders.Length > 0)
                {
                    return(forwardedHeaders[0]);
                }
            }

            return(string.Empty);
        }
示例#2
0
        string TryLookupForwardHeader(HttpRequestBase httpRequest, LogEventInfo logEvent)
        {
            var headerName      = ForwardedForHeader.Render(logEvent);
            var forwardedHeader = httpRequest.Headers[headerName];

            if (!string.IsNullOrEmpty(forwardedHeader))
            {
                var addresses = forwardedHeader.Split(',');
                if (addresses.Length > 0)
                {
                    return(addresses[0]);
                }
            }

            return(string.Empty);
        }