CloudFlare kullanan veya daha değişik hosting firmalarında kullanıcıların ip adresini bulmak normal ip adresi alma koduyla sıkıntı yaratıyor.

çözüm:

VB.NET için

    Function getIPAdres() As String
        Dim xf As String = HttpContext.Current.Request.ServerVariables("HTTP_X_FORWARDED_FOR")
        Dim ra As String = HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")
        Dim hc As String = HttpContext.Current.Request.ServerVariables("HTTP_CLIENT-IP")

        If String.IsNullOrEmpty(hc) = True And String.IsNullOrEmpty(xf) = True Then
            Return ra
        ElseIf String.IsNullOrEmpty(hc) = False Then
            Return hc
        ElseIf String.IsNullOrEmpty(xf) = False Then
            Return xf
        Else
            Return ra
        End If
    End Function


C# için:

public string getIPAdres()
{
	string xf = HttpContext.Current.Request.ServerVariables("HTTP_X_FORWARDED_FOR");
	string ra = HttpContext.Current.Request.ServerVariables("REMOTE_ADDR");
	string hc = HttpContext.Current.Request.ServerVariables("HTTP_CLIENT-IP");

	if (string.IsNullOrEmpty(hc) == true & string.IsNullOrEmpty(xf) == true) {
		return ra;
	} else if (string.IsNullOrEmpty(hc) == false) {
		return hc;
	} else if (string.IsNullOrEmpty(xf) == false) {
		return xf;
	} else {
		return ra;
	}
}