Click here to Skip to main content
15,885,176 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Recently I am having a new requirement, in which I have multiple WCF service call, they are calling and requesting response for each other, Now I wanted to retrieve IP address of calling WCF service in another WCF service.

Please help me, I would be grate appreciated.
Posted
Comments
PIEBALDconsult 16-Mar-15 1:03am    
Why?
yogesh kumar14 16-Mar-15 1:14am    
Please Help if you know, How to get IP address of WCF Call
Sergey Alexandrovich Kryukov 16-Mar-15 1:21am    
Why?
—SA
yogesh kumar14 16-Mar-15 1:15am    
Its Requirement of the client
PIEBALDconsult 16-Mar-15 1:19am    
Ask them why?

1 solution

If your WCF's are hosted in a web server environment you can do the following:

In your config file:
C#
<system.servicemodel>
        !-- this enables WCF services to access ASP.Net http context -->
        <servicehostingenvironment aspnetcompatibilityenabled="true" />
</system.servicemodel>


You should then be able to access the client IP using:

C#
HttpContext.Current.Request.UserHostAddress
 
Share this answer
 
Comments
yogesh kumar14 16-Mar-15 1:28am    
Should I configure and write this code in second WCF service
Gideon van Dyk 16-Mar-15 17:28pm    
Would have thought it self explanatory. :)

The setup is required on the receiver side, so I recon "second WCF service" would be similar :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900