Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obtaining client IP address in WCF 3.0

Tags:

wcf

Apparently you can easily obtain a client IP address in WCF 3.5 but not in WCF 3.0. Anyone know how?

like image 244
Gaz Avatar asked Sep 18 '08 14:09

Gaz


People also ask

How do I get client IP from request?

In Java, you can use HttpServletRequest. getRemoteAddr() to get the client's IP address that's accessing your Java web application.

What is IP client?

Client IP means proprietary systems, software, information, logos, services names, domain names, marks and copyrights the Client uses.


1 Answers

This doesn't help you in 3.0, but I can just see people finding this question and being frustrated because they are trying to get the client IP address in 3.5. So, here's some code which should work:

using System.ServiceModel; using System.ServiceModel.Channels;  OperationContext context = OperationContext.Current; MessageProperties prop = context.IncomingMessageProperties; RemoteEndpointMessageProperty endpoint =     prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; string ip = endpoint.Address; 
like image 151
Paul Mrozowski Avatar answered Oct 13 '22 01:10

Paul Mrozowski