How to get IP address of each terminal (which is running the ASP.NET application) instead of the hosting machine's IP address?

Posted on 2004-11-17
Last Modified: 2008-02-01
If my ASP.NET application runs on an IIS server, and there is a group of severl WYSE thin client terminals which runs this application (i think it has their own IP address), i found if I used the traditional way to get IP address (the code listed at the end), the IP address or hostname shown on these terminals are the same: hosting machine's IP address or hostname. Apparently, it's not what I want: each terminal shows their own IP address or hostname when they run this application. Is there any way to show their own IP address in their browser? Any comment is welcome. Below is my code which works well to get the first byte of the IP address of the hosting machine, thanks a lot!

IPHostEntry HostInfo = Dns.GetHostByName("");  
IPAddress [] IpAddr = HostInfo.AddressList;      //IP string
byte [] IpBytes = IpAddr[0].GetAddressBytes();      //four bytes
string FirstByte = IpBytes[0].ToString();
Question by:heyday2004
    LVL 21

    Assisted Solution

    Request.ServerVariables[28] should give the Hosting ip Address

    Request.ServerVariables[32] should give the ip address of the machine that runs it
    Request.ServerVariables[33] should give the ip address of the machine that runs it

    Please let me know if it works
    LVL 28

    Accepted Solution

    Hi heyday2004,

    you can use Request.UserHostAddress to get IP address of the computer that request the application and
    Request.UserHostName to get the DNS name


    Author Comment

    Thanks a lot for the answer. I tried Request.ServerVariables[32], Request.UserHostName (supposed to print out a user machine name instead of IP address), but both printed "",  I know this local host IP address, i.e.  when a machine sends an IP packet to it ( , it is sending to itself. Of course, what I want is not that, i want the client machine's user name. Any help is appreciated! Thanks a lot!

    Author Comment

    I got the hostname successfully finally. The code is below:
    string client = Request.UserHostName;
    return (System.Net.Dns.GetHostByAddress(client)).HostName;

    So now, i just wonder why  Request.UserHostName returns IP address? thanks a lot.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now