Exemple #1
0
        /// <summary>
        /// 处理访问参数
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private AccessLogEntity InitAccessLog(System.Web.HttpContext context)
        {
            string          realIp  = GetRealClientIp(context);
            string          urlHost = new RequestHelp().GetHost(context);
            string          urlRaw  = context.Request.RawUrl.ToString();
            AccessLogEntity entity  = new AccessLogEntity();

            entity.WebSiteName = urlHost;
            entity.UrlAddress  = context.Request.Url.ToString();
            if (context.Session != null)
            {
                entity.SessionID = context.Session.SessionID;
            }
            if (context.Request != null)
            {
                entity.IPAddress       = realIp;
                entity.Browser         = context.Request.Browser.Browser;
                entity.BrowserID       = context.Request.Browser.Id;
                entity.BrowserVersion  = context.Request.Browser.Version;
                entity.BrowserType     = context.Request.Browser.Type;
                entity.BrowserPlatform = context.Request.Browser.Platform;
                if (context.Request.UrlReferrer != null)
                {
                    entity.PUrlAddress = context.Request.UrlReferrer.ToString();
                }
            }
            entity.EnabledMark = true;
            return(entity);
        }
Exemple #2
0
        /// <summary>
        /// 处理访问参数
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private RequestLogEntity InitEndRequestLog(System.Web.HttpContext context)
        {
            string           realIp  = GetRealClientIp(context);
            string           urlHost = new RequestHelp().GetHost(context);
            string           urlRaw  = context.Request.RawUrl.ToString();
            RequestLogEntity entity  = new RequestLogEntity();

            entity.UrlAddress  = context.Request.Url.ToString();
            entity.UrlHost     = urlHost;
            entity.UrlRaw      = urlRaw;
            entity.WebSiteName = urlHost;
            if (context.Session != null)
            {
                entity.SessionID = context.Session.SessionID;
            }
            if (context.Request != null)
            {
                entity.IPAddress       = realIp;
                entity.Browser         = context.Request.Browser.Browser;
                entity.BrowserID       = context.Request.Browser.Id;
                entity.BrowserVersion  = context.Request.Browser.Version;
                entity.BrowserType     = context.Request.Browser.Type;
                entity.BrowserPlatform = context.Request.Browser.Platform;
                if (context.Request.UrlReferrer != null)
                {
                    entity.PUrlAddress = context.Request.UrlReferrer.ToString();
                }
            }
            entity.EnabledMark = true;

            HttpCookie cookie = context.Request.Cookies.Get(CLINETID);

            if (cookie != null && !string.IsNullOrEmpty(cookie.Value))
            {
                entity.ClientID = cookie.Value;
            }
            else
            {
                string clientIds = Guid.NewGuid().ToString();
                entity.ClientID = clientIds;
                cookie          = new HttpCookie(CLINETID);
                cookie.Name     = CLINETID;
                cookie.Value    = clientIds;
                cookie.Expires  = DateTime.Now.AddYears(1);
                entity.ClientID = clientIds;

                context.Response.Cookies.Set(cookie);
            }
            entity.StartDateTime = context.Timestamp;
            return(entity);
        }