2009-10-26 29 views

cevap

9
HttpContext.Current.Request.UserHostAddress; 

veya

HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; 

makinenin IP adresini almak için değil, vekil aşağıdaki kullanmak kodu

HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; 
+0

@Lance: İyi nokta. Bu konuda daha fazla bilgi için: http://en.wikipedia.org/wiki/X-Forwarded-ForLife Harper'a göre –

+0

. Çalışıyor ama çalışmayan bir ve üçüncüsü nedir? –

3

HttpContext.Current.Request.UserHostAddress

+1

IIS7 için, localhost'un 'Request.UserHostAddress'' '1' döndürdüğünü ve' 127.0.0.1' döndürmediğini unutmayın. –

+0

ya işliyor Bay o.k.w –

2

Dene:

Request.ServerVariables["REMOTE_ADDR"].ToString() 
+0

teşekkür ederim o çalışıyor BayJay Riggs –