public ContextProperties GetContextProperties() { var props = new ContextProperties(); if (HttpContext.Current == null) { return(props); } HttpRequest request = null; try { request = HttpContext.Current.Request; } catch { } if (request != null) { props.UserAgent = request.Browser == null ? string.Empty : request.Browser.Browser; props.RemoteHost = request.ServerVariables == null ? string.Empty : request.ServerVariables["REMOTE_HOST"]; props.Path = request.Url == null ? string.Empty : request.Url.AbsolutePath; props.Query = request.Url == null ? string.Empty : request.Url.Query; props.RemoteHost = request.UrlReferrer == null ? string.Empty : request.UrlReferrer.ToString(); props.Method = request.HttpMethod; } var items = HttpContext.Current.Items; if (items != null) { var requestId = items["RequestId"]; if (requestId != null) { props.RequestId = requestId.ToString(); } } var session = HttpContext.Current.Session; if (session != null) { var sessionId = session["SessionId"]; if (sessionId != null) { props.SessionId = sessionId.ToString(); } } return(props); }
public ContextProperties GetContextProperties() { var props = new ContextProperties(); if (HttpContext.Current == null) { return props; } HttpRequest request = null; try { request = HttpContext.Current.Request; } catch { } if (request != null) { props.UserAgent = request.Browser == null ? string.Empty : request.Browser.Browser; props.RemoteHost = request.ServerVariables == null ? string.Empty : request.ServerVariables["REMOTE_HOST"]; props.Path = request.Url == null ? string.Empty : request.Url.AbsolutePath; props.Query = request.Url == null ? string.Empty : request.Url.Query; props.RemoteHost = request.UrlReferrer == null ? string.Empty : request.UrlReferrer.ToString(); props.Method = request.HttpMethod; } var items = HttpContext.Current.Items; if (items != null) { var requestId = items["RequestId"]; if (requestId != null) { props.RequestId = requestId.ToString(); } } var session = HttpContext.Current.Session; if (session != null) { var sessionId = session["SessionId"]; if (sessionId != null) { props.SessionId = sessionId.ToString(); } } return props; }