troubleshooting Question

How to get an IPAddress from within a CodeBehind aspx page

Avatar of MikeCombe
MikeCombeFlag for United States of America asked on
6 Comments2 Solutions228 ViewsLast Modified:
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?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros