悬赏园豆:5
[已解决问题]
解决于 2008-05-29 08:13
<P>1.string struserIP = System.Web.HttpContext.Current.Request.UserHostAddress <BR>2. private string GetClientIP() <BR> { <BR> string result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; <BR> if (null == result ¦ ¦ result == String.Empty) <BR> { <BR> result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; <BR> } <BR> if (null == result ¦ ¦ result == String.Empty) <BR> { <BR> result = HttpContext.Current.Request.UserHostAddress; <BR> } <BR> return result; <BR> } <BR>得到的数据是服务器内网的IP地址,为何?2种方式得到的值是一样。 <BR>哪位朋友知道,不胜感激。</P>
<P>服务器是通过DNS中转的,得到的是服务器DNS的内网IP地址。 <BR>为何获取不了客户端的IP。</P>
★金★
|
初学一级
|
园豆:
190
提问于:2008-05-16 09:35