private IEnumerable <KeyValuePair <string, string> > GetGlobalParameters() { if (!string.IsNullOrEmpty(Culture)) { yield return(new KeyValuePair <string, string>("c", Culture)); } if (UserLocation != null) { yield return(new KeyValuePair <string, string>("userLocation", UserLocation.ToString())); } if (UserMapView != null) { yield return(new KeyValuePair <string, string>("userMapView", string.Concat(UserMapView.SouthWest.ToString(), ",", UserMapView.NorthEast.ToString()))); } if (UserIP != null) { yield return(new KeyValuePair <string, string>("userIp", UserIP.ToString())); } if (IncludeNeighborhood) { yield return(new KeyValuePair <string, string>("inclnb", IncludeNeighborhood ? "1" : "0")); } if (MaxResults != null && MaxResults.Value > 0) { yield return(new KeyValuePair <string, string>("maxResults", Math.Min(MaxResults.Value, BINGMAXRESULTSVALUE).ToString())); } }
public ViewResult List(string category, int page = 1) { //-- user ip should get-------------------- UserIP userIP = new UserIP(); string ip = userIP.GetClientIpaddress(); int howLong = ip.Length; if (ip != null && ip != "::1") // this is if running on local server { ip = ip.Remove(14, howLong - 14); // deleting some digits which are always different } //remenber if (Session["IP"] == null || Session["IP"].ToString() != ip) // if something is null then you cant comapare like this, first you have to comapare to null { if (ip != "37.228.244.103" && ip != "::1") { Session["IP"] = userIP.GetClientIpaddress(); EmailOrderProcessor email = new EmailOrderProcessor(new EmailSettings()); email.FromServerPayPal(userIP.GetClientIpaddress()); if (ip != null && ip != "::1") { // this is if running on local server the number ::1 this is server on my computer howLong = Session["IP"].ToString().Length; Session["IP"] = Session["IP"].ToString().Remove(14, howLong - 14); // from 14 digit next six digits remve } } } //-------------------------------------------- ProductsListViewModel viewModel = new ProductsListViewModel { MyItems = repository.Myitems.Where(p => category == null || p.Category == category).OrderBy(p => p.NumberID).Skip((page - 1) * PageSize).Take(PageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = category == null?repository.Myitems.Count() : repository.Myitems.Where(e => e.Category == category).Count() }, CurrentCategory = category }; return(View(viewModel)); }
/// <summary> /// 快网CDN专用取IP方法 ygj 2011-6-15 团卡前台用的快网CDN,必须掉这个方法 /// </summary> /// <returns></returns> public static string getRealIp_byKW() { string UserIP; if (!string.IsNullOrEmpty(HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"])) { UserIP = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; } else { UserIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; } UserIP = UserIP.Replace(";", ","); UserIP = UserIP.Replace(";", ","); UserIP = UserIP.Replace(",", ","); UserIP = StringUtil.GetFirstIp(UserIP); return(UserIP); }
public static string getRealIp() { string UserIP; if (HttpContext.Current.Request.Headers["Cdn-Src-Ip"] != null) { UserIP = HttpContext.Current.Request.Headers["Cdn-Src-Ip"]; } else if (!string.IsNullOrEmpty(HttpContext.Current.Request.ServerVariables["HTTP_VIA"])) //得到穿过代理服务器的ip地址 { if (!string.IsNullOrEmpty(HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"])) { UserIP = StringUtil.GetFirstIp(HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]); } else { UserIP = HttpContext.Current.Request.ServerVariables["HTTP_VIA"]; } } else { if (!string.IsNullOrEmpty(HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"])) { UserIP = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; } else { UserIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; } UserIP = UserIP.Replace(";", ","); UserIP = UserIP.Replace(";", ","); UserIP = UserIP.Replace(",", ","); UserIP = StringUtil.GetFirstIp(UserIP); } return(UserIP); }
public override bool Equals(object obj) { if (ReferenceEquals(this, obj)) { return(true); } if ((object)this == null || obj == null) { return(false); } User u = obj as User; if (u.Nickname.Equals(Nickname) && u.UserIP.ToString().Equals(UserIP.ToString())) { return(true); } else { return(false); } }
void ISerializable.GetObjectData(SerializationInfo si, StreamingContext ctx) { si.AddValue("ipString", UserIP.ToString()); si.AddValue("nickString", Nickname); }