Hot to get the client IP from a web method

G

Guest

Hi,

Sorry to double post this one, but I think it fits in this group.

Is there a way to get the client IP from a web service? I keep receiving the
server's IP address.

From my web method, I tried all of this:

Context.Request.UserHostAddress;
Context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
Context.Request.ServerVariables["REMOTE_ADDR"];

Even by checking the headers, there's no client IP:

NameValueCollection NVCSrvElements = Context.Request.ServerVariables;
foreach(string item in NVCSrvElements.Keys)
{
Response.Write(item + " " + NVCSrvElements[item]);
}

Any idea?

Thanks,

Stephane
 
G

Guest

Stephane said:
Hi,

Sorry to double post this one, but I think it fits in this group.

Is there a way to get the client IP from a web service? I keep receiving the
server's IP address.

From my web method, I tried all of this:

Context.Request.UserHostAddress;
Context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
Context.Request.ServerVariables["REMOTE_ADDR"];

Even by checking the headers, there's no client IP:

NameValueCollection NVCSrvElements = Context.Request.ServerVariables;
foreach(string item in NVCSrvElements.Keys)
{
Response.Write(item + " " + NVCSrvElements[item]);
}

Any idea?

Thanks,

Stephane


I'm not an expert at this, but if someone comes to your app from behind a
firewall, the only IP Address is of the firewall. My org has 3000 people, but
only two IP Addresses that are read outside the organization.

Clint
 
M

Mark Rae

string ipAddress = this.Context.Request.UserHostAddress;

Not that it will do you much good, though.
Proxies abound on the net.

Quite so - it's almost not worth the bother...
 
G

Guest

Well, when we create a web service, a proxy is ceated to call the service. So
even though my server is not behind a proxy, the IP address is always the
server's.

I was wondering if there was a work around... I guess not!

Thanks

Stephane
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top