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. Web Development
  3. ASP.NET
  4. Which one is the Best way?? (client IP address)

Which one is the Best way?? (client IP address)

Scheduled Pinned Locked Moved ASP.NET
performancequestion
5 Posts 3 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.
  • J Offline
    J Offline
    Jagadeesh Jupalli
    wrote on last edited by
    #1

    Hi, I am able to get the client IP address using the following 3 ways string test = Request.UserHostAddress.ToString(); string test2 = Request.ServerVariables["REMOTE_ADDR"].ToString(); string test3 = Context.Request.UserHostAddress.ToString(); All are returning the same values... But which one is the Best (accuracy and performance wise) and More reliable in all respects. Which one should I use?? Regards, ~JJ

    M G 2 Replies Last reply
    0
    • J Jagadeesh Jupalli

      Hi, I am able to get the client IP address using the following 3 ways string test = Request.UserHostAddress.ToString(); string test2 = Request.ServerVariables["REMOTE_ADDR"].ToString(); string test3 = Context.Request.UserHostAddress.ToString(); All are returning the same values... But which one is the Best (accuracy and performance wise) and More reliable in all respects. Which one should I use?? Regards, ~JJ

      M Offline
      M Offline
      Mogaambo
      wrote on last edited by
      #2

      which ever you like

      J 1 Reply Last reply
      0
      • M Mogaambo

        which ever you like

        J Offline
        J Offline
        Jagadeesh Jupalli
        wrote on last edited by
        #3

        Mogaambo kush hua :)

        M 1 Reply Last reply
        0
        • J Jagadeesh Jupalli

          Mogaambo kush hua :)

          M Offline
          M Offline
          Mogaambo
          wrote on last edited by
          #4

          ha ha ha ha ha :-D :laugh: :laugh: :laugh: :laugh: :laugh:

          1 Reply Last reply
          0
          • J Jagadeesh Jupalli

            Hi, I am able to get the client IP address using the following 3 ways string test = Request.UserHostAddress.ToString(); string test2 = Request.ServerVariables["REMOTE_ADDR"].ToString(); string test3 = Context.Request.UserHostAddress.ToString(); All are returning the same values... But which one is the Best (accuracy and performance wise) and More reliable in all respects. Which one should I use?? Regards, ~JJ

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            They are all the same. However, they are already strings, so there is no reason to use ToString:

            string test = Request.UserHostAddress;
            string test2 = Request.ServerVariables["REMOTE_ADDR"];
            string test3 = Context.Request.UserHostAddress;

            Also:

            string test4 = Context.Request.ServerVariables["REMOTE_ADDR"];
            string test5 = Page.Request.UserHostAddress;
            string test6 = Page.Request.ServerVariables["REMOTE_ADDR"];
            string test7 = Page.Page.Request.UserHostAddress;
            string test8 = Page.Page.Request.ServerVariables["REMOTE_ADDR"];
            string test9 = HttpContext.Current.Request.UserHostAddress;
            string test10 = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
            string test11 = ((Page)(HttpContext.Current.Handler)).Request.UserHostAddress;
            string test12 = ((Page)(HttpContext.Current.Handler)).Request.ServerVariables["REMOTE_ADDR"];
            string test13 = ((Page)(HttpContext.Current.Handler)).Page.Request.UserHostAddress;
            string test14 = ((Page)(HttpContext.Current.Handler)).Page.Request.ServerVariables["REMOTE_ADDR"];

            Despite everything, the person most likely to be fooling you next is yourself.

            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