Collect Visitor's IP
-
Anyone got a link to a good tutorial which shows how to create a read-only text-box in a Web Application which automatically collects a visitor's IP Address? Thanks
It's in the Request object ( the IP address ). Use a label, that's read only.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
Anyone got a link to a good tutorial which shows how to create a read-only text-box in a Web Application which automatically collects a visitor's IP Address? Thanks
Here you go...
txtbox.Text = Request.ServerVariables["REMOTE_HOST"];
txtbox.Attribures.Add("readonly", "readonly");. :)
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
-
Anyone got a link to a good tutorial which shows how to create a read-only text-box in a Web Application which automatically collects a visitor's IP Address? Thanks
public static string GetLocalAddress()
{
IPAddress[] addressLocal = Dns.GetHostByName(Dns.GetHostName()).AddressList;
if (addressLocal.Length > 0)
{
return addressLocal[addressLocal.Length - 1].ToString();
}
return "127.0.0.1";}
-
It's in the Request object ( the IP address ). Use a label, that's read only.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
public static string GetLocalAddress()
{
IPAddress[] addressLocal = Dns.GetHostByName(Dns.GetHostName()).AddressList;
if (addressLocal.Length > 0)
{
return addressLocal[addressLocal.Length - 1].ToString();
}
return "127.0.0.1";}
This would always give the server address.
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
Why was this reply voted one?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
Because, he did not give him the complete code snippet. ;P
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.