摘要:
C#获取客户端IP。最近遇到一个需要做鉴权的接口,有IP鉴权的需求,需要知道客户端HTTP请求的IP。试了好多种方法,发现都有问题。最终尝试 ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];后来遇到负载均衡的时候,获取到的总是负载均衡的服务器。换了种获取方式 ip = HttpContex... 阅读全文
摘要:
public class HttpPost { public string SendAll(string Url, string jsonString) { #region 发送HTTP POST 数据 HttpWebRequest httpWebRequest = WebRequest.Create(Url) as HttpWebRequest;//定义对象 httpWebRequest.Method = "POST";//设置提交方式 支持POST PUT GET DELETE ... 阅读全文