将指定的IP转移到其他网址 [英] transfer specifed IP to other Web Address

查看:136
本文介绍了将指定的IP转移到其他网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找代码,以帮助我将具有指定IP的网站访问者转移到其他网址

I am looking for the code that help me to transfer the web site visitor with specifed IP to other web address

推荐答案

您可以获取客户端在下面使用此代码(即使客户端使用代理,它也会获得真实的客户端ip)

You can get the actual ip of the client using this code below (it will get the real client ip, even if the client is using a proxy)

string ip = Request.ServerVariables("HTTP_X_FORWARDED_FOR");
if (!string.IsNullOrEmpty(ip))
{
   string[] ipRange = ip.Split(',');
   ip = ipRange[0];
}
else
{
   ip=Request.ServerVariables("REMOTE_ADDR");
}



使用Response.Redirect可以相当简单地完成该操作.

祝您好运!



The can be done rather simple using a Response.Redirect.

Good luck!


感谢您的答复,您知道任何限制每个IP地址和相关国家/地区的IP表吗?
thank you for your reply, do you know any IP table that confine the location and related country of each IP ?


这篇关于将指定的IP转移到其他网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆