ASP.NET

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentASP.NET

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old December 2nd, 2016, 06:45 AM
prashants prashants is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Dec 2016
Posts: 1 prashants User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 22 sec
Reputation Power: 0
Question How to get Client machine IP address after hosting an ASP.NET application in server

How to get Client machine IP address after hosting an application in server.
I am getting client Ip if I run my application locally but if I put the same code in server ,that code is not working properly. Please anybody help me.

Here is my code....

public void GetIP4Address()
{
string IP4Address = String.Empty;

foreach (IPAddress IPA in Dns.GetHostAddresses(HttpContext.Current.Request.U serHostAddress))
{
if (IPA.AddressFamily.ToString() == "InterNetwork")
{
IP4Address = IPA.ToString();
break;
}
}

if (IP4Address != String.Empty)
{
Label1.Text= IP4Address;
}

foreach (IPAddress IPA in Dns.GetHostAddresses(Dns.GetHostName()))
{
if (IPA.AddressFamily.ToString() == "InterNetwork")
{
IP4Address = IPA.ToString();
break;
}
}

Label1.Text= IP4Address;
}

Its giving IP in local as "192.168.12.97" and giving "192.168.1.6" IP if I run in server.

I want to fetch "192.168.12.97" this IP both in local n server.

Please help me...


ASP.NET - GEt Client IP Address from Browser

Reply With Quote
  #2  
Old December 6th, 2016, 12:06 AM
Smith-K Smith-K is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Dec 2016
Location: Leeds, UK
Posts: 2 Smith-K User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 18 sec
Reputation Power: 0
Did you try using following?

Code:
Request.UserHostAddress

Request.UserHostName


Refer to following answer posted on a different threads

http://stackoverflow.com/questions/7462188/get-clients-ip-address-and-computer-name
http://stackoverflow.com/questions/735350/how-to-get-a-users-client-ip-address-in-asp-net

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentASP.NET > How to get Client machine IP address after hosting an ASP.NET application in server


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap