Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Web services question...

Web services question...

Scheduled Pinned Locked Moved C#
questionwcf
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Manster
    wrote on last edited by
    #1

    Hi, Can anyone tell me how a web service would get the calling computers IPAddress? I'm new to web services and I'm not sure where to look for this type of information. It's probably something really obvious that I'm unaware of. Thanks

    H 1 Reply Last reply
    0
    • M Manster

      Hi, Can anyone tell me how a web service would get the calling computers IPAddress? I'm new to web services and I'm not sure where to look for this type of information. It's probably something really obvious that I'm unaware of. Thanks

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Domain Name Services, or DNS. This is all handled by the TCP/IP stack on your machine. This is what resolves names like www.codeproject.com to IP addresses like 209.171.52.99.

      Microsoft MVP, Visual C# My Articles

      M 1 Reply Last reply
      0
      • H Heath Stewart

        Domain Name Services, or DNS. This is all handled by the TCP/IP stack on your machine. This is what resolves names like www.codeproject.com to IP addresses like 209.171.52.99.

        Microsoft MVP, Visual C# My Articles

        M Offline
        M Offline
        Manster
        wrote on last edited by
        #3

        Heath, I looked at the Dns class, but I didn't see anything obvious that would help me find out the calling computers ip address of my web service. Is their a way to do this? Thanks

        H 1 Reply Last reply
        0
        • M Manster

          Heath, I looked at the Dns class, but I didn't see anything obvious that would help me find out the calling computers ip address of my web service. Is their a way to do this? Thanks

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          You can use Dns.GetHostByName (or the asynchronous BeginGetHostByName) to get the IP address, but you don't need to in most cases. When the proxy makes a request to the remote Web Services via its URL, the DNS client of your local machine will resolve the IP address, connect to the server, and make the request on the Web Service. This is all done internally - you do not need to resolve the IP address manually, just like you don't need to use the IP address in Internet Explorer and other Internet-ready applications.

          Microsoft MVP, Visual C# My Articles

          M 1 Reply Last reply
          0
          • H Heath Stewart

            You can use Dns.GetHostByName (or the asynchronous BeginGetHostByName) to get the IP address, but you don't need to in most cases. When the proxy makes a request to the remote Web Services via its URL, the DNS client of your local machine will resolve the IP address, connect to the server, and make the request on the Web Service. This is all done internally - you do not need to resolve the IP address manually, just like you don't need to use the IP address in Internet Explorer and other Internet-ready applications.

            Microsoft MVP, Visual C# My Articles

            M Offline
            M Offline
            Manster
            wrote on last edited by
            #5

            So all I need to do is add this code to my web service and this will get the calling programs ip address? string sHostName = Dns.GetHostName(); IPHostEntry ipEntry = Dns.GetHostByName( sHostName ); string sCallingAppName = ipEntry.HostName; Thanks

            H 1 Reply Last reply
            0
            • M Manster

              So all I need to do is add this code to my web service and this will get the calling programs ip address? string sHostName = Dns.GetHostName(); IPHostEntry ipEntry = Dns.GetHostByName( sHostName ); string sCallingAppName = ipEntry.HostName; Thanks

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              If you want to log the IP address of the machine making the request to your web service, all you need to do us is get Context.Request.UserHostAddress inside a method call in your web service (Context is a property inheritted from the WebService from which your web service derives).

              Microsoft MVP, Visual C# My Articles

              M 1 Reply Last reply
              0
              • H Heath Stewart

                If you want to log the IP address of the machine making the request to your web service, all you need to do us is get Context.Request.UserHostAddress inside a method call in your web service (Context is a property inheritted from the WebService from which your web service derives).

                Microsoft MVP, Visual C# My Articles

                M Offline
                M Offline
                Manster
                wrote on last edited by
                #7

                Thanks so much for your help, this is exactly what I needed. :)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups