c# - 来自httpheader的请求的ip地址

标签 c# http-headers ip-address

我正在尝试获取来自 http header 的请求的 IP 地址。如果值为 x 则做某事,否则做其他事。谁能帮帮我?

最佳答案

是否this帮助?这看起来很简单。

从链接中,有几种不同的方式:

HttpContext.Current.Request.UserHostAddress;

HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

关于c# - 来自httpheader的请求的ip地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5585916/

相关文章:

java - 在 Spring 中添加 Accept header

ruby-on-rails - 如何防止 Rails 中的浏览器页面缓存

javascript - 根据编码的formData值设置 Node 请求头

google-app-engine - Google App Engine - urlFetch 地址不在 _netblocks.google.com 中

C# 从 wiki 页面抓取数据(屏幕抓取)

c# - Request.UrlReferrer.ToString() ->System.NullReferenceException : Object reference not set to an instance of an object

c# - 为什么 Assembly.GetTypes() 需要引用?

django - 如何在数据库和django admin中存储IP地址

c++ - 如何以编程方式设置系统IP

c# - 如何检查 WPF TextBox TextChange 事件中添加文本的长度?