Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 1st, 2010, 07:40 PM
Authorized User
Join Date: May 2007
Posts: 73
Thanks: 4
Thanked 0 Times in 0 Posts
Default get user ip address

I want to capture user ip address but some reason i am getting different values:
method 1:

Dim strHostName As String = System.Net.Dns.GetHostName()
Dim clientIPAddress As String = System.Net.Dns.GetHostAddresses(strHostName).GetVa lue(0).ToString()
method 2:
Dim k As String = Request.ServerVariables("remote_addr")

Donno which one i should use.

Old June 2nd, 2010, 03:59 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

Check out the IntelliSense help tooltip or the MSDN documentation for GetHostName:


Dns.GetHostName Method

Gets the host name of the local computer.


Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
Sheraz Khan (June 9th, 2010)
Old June 2nd, 2010, 07:41 PM
Friend of Wrox
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

HINT: "Local computer" means the one the web server is running on.

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get the IP address of the user viewing site crmpicco Perl 2 April 30th, 2007 06:51 AM
IP address of the user. 99mary BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 March 26th, 2007 09:23 AM
Help me i must Get IP Address pla_2 C# 2005 2 October 12th, 2006 07:51 AM
How to get IP Address of the User Machine pkdev Classic ASP Basics 2 April 10th, 2004 01:44 PM
Retreiving IP address & gateway address sjangit VBScript 0 February 3rd, 2004 02:02 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.