Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get client IP address in a WCF Service hosted using HTTPS 443 bindings

In one of my application in need client IP address in a WCF Service hosted using HTTPS 443 bindings.

and i tried most of the post of stack overflow and other site regarding this issue but when i hosted my application in server it just fetch server IP address but i need requested client address any have any idea regarding this

Thanks In advance..

like image 569
andy Avatar asked Jun 15 '12 09:06

andy


1 Answers

In .NET 3.5 you can do using the below pattern (using System.ServiceModel)

OperationContext context = OperationContext.Current; 
MessageProperties prop = context.IncomingMessageProperties; 
RemoteEndpointMessageProperty endpoint = prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
string ip = endpoint.Address; 
like image 71
Gupta Vini Avatar answered Oct 05 '22 09:10

Gupta Vini