Hey Reader,
Use this code of C#, I think it might be helpful to you.
Dim strIpAddress As String = GetIPAddress()
Dim strgetserverlocation As String = GetServerInfo()
Dim Datetime__1 As String = Convert.ToString(DateTime.Now)
Public Function GetIPAddress() As String
Try
Dim ipAdd As String
Dim currentRequest As HttpRequest = HttpContext.Current.Request
ipAdd = currentRequest.ServerVariables("HTTP_X_FORWARDED_FOR")
If ipAdd Is Nothing OrElse ipAdd.ToLower() = "unknown" Then
ipAdd = currentRequest.ServerVariables("REMOTE_ADDR")
End If
Return ipAdd
Catch ex As Exception
Throw ex
End Try
End Function
Public Function GetServerInfo() As String
Try
Dim Sinfo As String
Dim currentRequest As HttpRequest = HttpContext.Current.Request
Sinfo = currentRequest.ServerVariables("HTTP_X_FORWARDED_FOR")
If Sinfo Is Nothing OrElse Sinfo.ToLower() = "unknown" Then
Sinfo = currentRequest.ServerVariables("REMOTE_ADDR")
Sinfo += "/" + currentRequest.ServerVariables("LOGON_USER")
End If
Dim computerinfo As String() = Sinfo.Split("/"c)
Return computerinfo(1)
Catch ex As Exception
Throw ex
End Try
End Function