find a location for property in a new city

Wednesday, 16 March 2011

WCF REST: How to get an IP address of a request

It seems to be quite difficult to find the IP of the request when in the Context of a WCF REST service.

I found you can do it with the following code:
var props = OperationContext.Current.IncomingMessageProperties;
var endpointProperty = props[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
if (endpointProperty != null)
{
    var ip = endpointProperty.Address;
}

This seems overly verbose so you may want to consider putting this code into helper methods or a base class for re-use.

More WCF REST:

Follow britishdev on Twitter

11 comments:

  1. A British IP address is one of the most popular IP addresses in the world. British IP Address

    ReplyDelete
  2. Thanks so much with this fantastic new web site. very fired up to show it to anyone. It makes me so satisfied your vast understanding and wisdom have a new channel for trying into the world. lemigliorivpn

    ReplyDelete
  3. Incredibly composed blog that has transfixed its group of onlookers.
    192.168.o.1

    ReplyDelete
  4. Latest sports news headlines from India and world. Check out today's most recent & up-to-date news coverage, videos & photos at thesportsrumour.com
    sports news

    ReplyDelete
  5. I am impressed. I don't think Ive met anyone who knows as much about this subject as you do. You are truly well informed and very intelligent. You wrote something that people could understand and made the subject intriguing for everyone. Really, great blog you have got here. https://192-168-i-i.com

    ReplyDelete
  6. Motifz Designer Lawn. 1, 2 & 3 Piece Unstitched Premium Embroidered Lawn 2019, Premium embroidered Lawn, Premium lawn, Premium lawn 2019, Motifz, Premium lawn in Pakistan, Summer collection. Shipping worldwide. Stitching option available.

    ReplyDelete
  7. Wow this was amazing. I was just about to look for some expert and educative content like this, I am grateful that I have frequented here! Cliquez-ici

    ReplyDelete
  8. Good composed article. It will be steady to any individual who uses it, including me. Continue doing what you are doing – can'r hold up to peruse more posts. Klik hier

    ReplyDelete
  9. I wish more authors of this type of content would take the time you did to research and write so well. I am very impressed with your vision and insight. Meer hierover leest je hier

    ReplyDelete
  10. Good composed article. It will be steady to any individual who uses it, including me. Continue doing what you are doing – can'r hold up to peruse more posts. internetet securite website

    ReplyDelete
  11. Very efficiently written information. It will be beneficial to anybody who utilizes it, including me. Keep up the good work. For sure i will check out more posts. This site seems to get a good amount of visitors. 192.168.49.1

    ReplyDelete