我想读取 X-Forwarded-For
的值请求中的 header 值。
我试过了
HttpContext.Current.Request.Headers["X-Forwarded-For"].Split(new char[] { ',' }).FirstOrDefault();
在 C# 中。
或者我是否需要用 ":"
拆分 header 并取第二个字符串?
我问这个是因为,维基百科说
The general format of the field is: X-Forwarded-For: client1, proxy1, proxy2
最佳答案
返回的格式是client1, proxy1, proxy2
所以你用逗号分开,第一个看到你客户端的ip。
关于c# - 读取 X-Forwarded-For header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6316796/