你的位置:首页 > 软件开发 > ASP.net > 302重定向,MVC中的Get,Post请求。

302重定向,MVC中的Get,Post请求。

发布时间:2015-09-06 11:00:24
1.在访问页遇到重定向,Get,Post跳转处理,在跳转后的页面获取访问端的IP,他们的IP是否发生变化。。。2.重定向处理后获取的IP还是访问端IP,而用Get,Post请求处理后,获取的访问端IP则是处理页的IP。3.获取客户端IP的代码 public string Get ...

302重定向,MVC中的Get,Post请求。

1.在访问页遇到重定向,Get,Post跳转处理,在跳转后的页面获取访问端的IP,他们的IP是否发生变化。。。

2.重定向处理后获取的IP还是访问端IP,而用Get,Post请求处理后,获取的访问端IP则是处理页的IP。

3.获取客户端IP的代码

  public get='_blank'>string GetClientIP()    {      HttpContext current = HttpContext.Current;      string userHostAddress = string.Empty;      if (current != null)      {        if ((current.Session != null) && (current.Session["cnki_sys_user_remote_addr"] != null))        {          userHostAddress = current.Session["cnki_sys_user_remote_addr"].ToString();          if (!string.IsNullOrEmpty(userHostAddress))          {            return userHostAddress;          }        }        userHostAddress = "127.0.0.1";        userHostAddress = current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];        if (string.IsNullOrEmpty(userHostAddress))        {          userHostAddress = current.Request.ServerVariables["REMOTE_ADDR"];          if (string.IsNullOrEmpty(userHostAddress))          {            userHostAddress = current.Request.UserHostAddress;          }        }        else        {          string[] strArray = userHostAddress.Split(new char[] { ',' });          if ((strArray.Length > 1) && !string.IsNullOrEmpty(strArray[strArray.Length - 1]))          {            userHostAddress = strArray[strArray.Length - 1];          }        }        if (current.Session != null)        {          current.Session["cnki_sys_user_remote_addr"] = userHostAddress;        }      }      return userHostAddress;    }

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:302重定向,MVC中的Get,Post请求。

关键词:post

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。