没有合适的资源?快使用搜索试试~ 我知道了~
.net C#开发 根据用户Ip地址获取省份城市
资源推荐
资源详情
资源评论
string ip = Request.UserHostAddress;
// Response.Redirect("http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip="+ip);
string PostUrl = "http://int.dpool.sina.com.cn/iplookup/iplookup.php?ip="+ip;
string res = GetDataByPost(PostUrl);
string [] ipAddress = getAreaInfoList(res);
public string GetDataByPost(string url)
{
string backstr = "";
try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
string s = "anything";
byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes(s);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = requestBytes.Length;
Stream requestStream = req.GetRequestStream();
requestStream.Write(requestBytes, 0, requestBytes.Length);
requestStream.Close();
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.Default);
backstr = sr.ReadToEnd();
sr.Close();
res.Close();
// Response.Redirect("http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip="+ip);
string PostUrl = "http://int.dpool.sina.com.cn/iplookup/iplookup.php?ip="+ip;
string res = GetDataByPost(PostUrl);
string [] ipAddress = getAreaInfoList(res);
public string GetDataByPost(string url)
{
string backstr = "";
try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
string s = "anything";
byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes(s);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = requestBytes.Length;
Stream requestStream = req.GetRequestStream();
requestStream.Write(requestBytes, 0, requestBytes.Length);
requestStream.Close();
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.Default);
backstr = sr.ReadToEnd();
sr.Close();
res.Close();
资源评论
- weixin_392086182019-07-21已经用不了..
清燚
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功