How to get an IPAddress from within a CodeBehind aspx page
I am trying to get the users IPAddress....from within a CodeBehind aspx page.
This is on my aspx page... test.aspx
which refers to --> CodeBehind="test.aspx.vb"
My function is this.....(inside test.aspx.vb)
Public Shared Function getIPAddress()
Dim IPAddress As String = ""
IPAddress = Request.ServerVariables("REMOTE_ADDR")
Return IPAddress
End Function
The error I get is this.....
Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
Can I get the IPAddress directly from inside the CodeBehind page?
Can I get it from the aspx page & pass it to the CodeBehind page?
Public Shared Function getIPAddress()
Dim IPAddress As String = ""
IPAddress = Request.UserHostAddress()
IPAddress = HttpWorkerRequest.GetRemoteAddress().ToString()
IPAddress = Context.Request.ServerVariables("REMOTE_ADDR")
Return IPAddress
End Function
Public Shared Function getIPAddress()
Dim IPAddress As String = ""
IPAddress = Request.UserHostAddress()
IPAddress = HttpWorkerRequest.GetRemot
IPAddress = Context.Request.ServerVari
Return IPAddress
End Function