Beispiel #1
0
 private static void BuildLogHeaders(HttpClient client, string token = "")
 {
     try
     {
         //登录信息
         //client.DefaultRequestHeaders.Authorization = CreateBasicCredentials(Ticket.LoginName, Ticket.Id, Ticket.ChineseName);
         //填充日志所需头
         if (HttpContext.Current != null)
         {
             var rid = HttpContext.Current.Items["__RIO_RequestID"] as string;
             if (rid == null)
             {
                 rid = Guid.NewGuid().ToString("N");
                 HttpContext.Current.Items["__RIO_RequestID"] = rid;
             }
             // client.DefaultRequestHeaders.Add("appkey", "M44NJ725jfnbT7PLkLfarvhpD2DZ7");//TODO 可配置 appkey
             client.DefaultRequestHeaders.Add("token", token);//TODO 可配置 appkey
             client.DefaultRequestHeaders.Add("X-RIO-RequestID", rid.UrlEncode());
             client.DefaultRequestHeaders.Add("X-RIO-UserIP", IPHelper.GetIP().UrlEncode());
             client.DefaultRequestHeaders.Add("X-RIO-LoginUserName", HttpContext.Current.User.Identity.Name.UrlEncode());
             client.DefaultRequestHeaders.Add("X-RIO-UserName", HttpContext.Current.User.Identity.Name.UrlEncode());
             client.DefaultRequestHeaders.Add("X-RIO-Url", HttpContext.Current.Request.Url.AbsoluteUri.UrlEncode());
             client.DefaultRequestHeaders.Add("X-RIO-UserAgent", HttpContext.Current.Request.UserAgent.UrlEncode());
             var referrer = HttpContext.Current.Request.UrlReferrer == null ? "" : HttpContext.Current.Request.UrlReferrer.AbsoluteUri;
             client.DefaultRequestHeaders.Add("X-RIO-Referer", referrer.UrlEncode());
         }
     }
     catch (Exception ex)
     {
         // WebLog.Error(ex);
     }
 }
Beispiel #2
0
 /// <summary>
 /// 获得当前页面客户端的IP
 /// </summary>
 /// <returns>当前页面客户端的IP</returns>
 public static string GetIP()
 {
     return(IPHelper.GetIP());
 }