private string UserData(string accessToken, string tokenType = null, Dictionary <string, string> additionalData = null) { var url = UserInfoServiceEndpoint; _userInfoData = new Dictionary <string, string>(); if (AccessTokenKeyword.IsEmpty()) { throw new Exception("UserInfoTokenKeyword must be set!"); } if (accessToken.IsEmpty()) { throw new Exception("AccessToken is null"); } if (AuthenticationType == AuthenticationTypes.PostData) { _userInfoData.Add(AccessTokenKeyword, accessToken); } else if (AuthenticationType == AuthenticationTypes.PostForm) { _userInfoData.Add(AccessTokenKeyword, accessToken); } if (additionalData != null) { foreach (var a in additionalData) { _userInfoData.Add(a.Key, a.Value); } } _userInfoHeader = new Dictionary <string, string>(); BeforeGetUserInfo(accessToken, _userInfoData, _userInfoHeader); if (AuthenticationType == AuthenticationTypes.PostData) { return(_webRequest.GetUrl(url, _userInfoData, _userInfoHeader)); } else if (AuthenticationType == AuthenticationTypes.PostForm) { return(_webRequest.PostForm(url, _userInfoData)); } else if (AuthenticationType == AuthenticationTypes.Header) { return(_webRequest.GetUrl(url, _userInfoData, _userInfoHeader, accessToken, tokenType)); } return(null); }
public string GetRealIp(HttpRequest request) { try { var client = new WebRequest2(); var response = client.GetUrl("http://checkip.dyndns.org", null); var a = response.Split(':'); var a2 = a[1].Substring(1); var a3 = a2.Split('<'); var a4 = a3[0]; return(a4 + " (" + GetIp(request) + ")"); } catch (Exception) { } var ip = request.HttpContext.Connection.RemoteIpAddress; return(ip.ToString()); }