Example #1
0
        public ContextProperties GetContextProperties()
        {
            ContextProperties props = new ContextProperties();

            if (HttpContext.Current != null)
            {
                HttpRequest request = null;
                try
                {
                    request = HttpContext.Current.Request;
                }
                catch (HttpException)
                {
                }
                if (request != null)
                {
                    props.UserAgent  = request.Browser == null ? "" : request.Browser.Browser;
                    props.RemoteHost = request.ServerVariables == null ? "" : request.ServerVariables["REMOTE_HOST"];
                    props.Path       = request.Url == null ? "" : request.Url.AbsolutePath;
                    props.Query      = request.Url == null ? "" : request.Url.Query;
                    props.Referrer   = request.UrlReferrer == null ? "" : request.UrlReferrer.ToString();
                    props.Method     = request.HttpMethod;
                }

                //var items = HttpContext.Current.Items;
                IDictionary items = HttpContext.Current.Items;
                if (items != null)
                {
                    var requestId = items["RequestId"];
                    if (requestId != null)
                    {
                        props.RequestId = items["RequestId"].ToString();
                    }
                }

                var session = HttpContext.Current.Session;
                if (session != null)
                {
                    var sessionId = session["SessionId"];
                    if (sessionId != null)
                    {
                        props.SessionId = session["SessionId"].ToString();
                    }
                }
            }

            return(props);
        }
Example #2
0
        public ContextProperties GetContextProperties()
        {
            ContextProperties props = new ContextProperties();
            if (HttpContext.Current != null)
            {
            HttpRequest request = null;
            try
            {
                request = HttpContext.Current.Request;
            }
            catch (HttpException)
            {
            }
                if (request != null)
            {
                props.UserAgent = request.Browser == null ? "" : request.Browser.Browser;
                props.RemoteHost = request.ServerVariables == null ? "" : request.ServerVariables["REMOTE_HOST"];
                props.Path = request.Url == null ? "" : request.Url.AbsolutePath;
                props.Query = request.Url == null ? "" : request.Url.Query;
                props.Referrer = request.UrlReferrer == null ? "" : request.UrlReferrer.ToString();
                props.Method = request.HttpMethod;
            }

            //var items = HttpContext.Current.Items;
            IDictionary items = HttpContext.Current.Items;
            if (items != null)
            {
                var requestId = items["RequestId"];
                if (requestId != null)
                {
                    props.RequestId = items["RequestId"].ToString();
                }
            }

            var session = HttpContext.Current.Session;
            if (session != null)
            {
                var sessionId = session["SessionId"];
                if (sessionId != null)
                {
                    props.SessionId = session["SessionId"].ToString();
                }
            }
            }

            return props;
        }