but it working correctly on localhost but when i am trying on the server it is giving as address like this 10.49.23.4 which address is this please reply me what is the problem....my email address is pank_manwatkar2007@yahoo.com thanks in advance....
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div>
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">if you need to use inside the class just pass it with the class</div>
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div>
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">ex code:</div>
inside the code behind page page.aspx.vb not inside a class and it will work
if you need to use inside the class just pass it with the class
ex code:
Imports Microsoft.VisualBasic
Public Class Testing
Public Shared Function TEsting(ByVal IPaddress As string) As String
'insert to database as log
dim IP as string = IPaddress
connect.ExecuteScaler("INSERT INTO blabla(IP_Address) " & _
"VALUES (" & IPaddress & ")")
Dim result As String = ""
Return result
End Function
End Class
in code behind page call the function and pass the IP
Manwatkar
Member
8 Points
4 Posts
Re: Get users IP address
Nov 05, 2009 09:44 AM|LINK
dear sir.
i have applied your code in my project
string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
but it working correctly on localhost but when i am trying on the server it is giving as address like this 10.49.23.4 which address is this please reply me what is the problem....my email address is pank_manwatkar2007@yahoo.com thanks in advance....
alikhanweb
Member
2 Points
1 Post
Re: Get users IP address
Nov 10, 2009 05:24 PM|LINK
This worked for me.
Thank you so much.
jamalqudah
Member
10 Points
11 Posts
Re: Get users IP address
Nov 15, 2009 06:42 PM|LINK
simply if you run the code on a class or the global you wont be able to get the remote IP address
just run this code on any code behind page and you'll get the remote user IP
Request.UserHostName
you can try my URL http://www.jamalq.com/testing.aspx
if you need the IP on the class just pass it through string
hope this help
samuel24
Member
167 Points
64 Posts
Re: Get users IP address
Dec 19, 2009 04:23 PM|LINK
Hi Getting users Ip address code is in the below link.may be it will useful for some one.
http://dotnetpgm.blogspot.com/2009/09/how-to-get-ip-address-in-aspnet.html
Get users IP address
http://www.dotnetpgm.blogspot.com
jamalqudah
Member
10 Points
11 Posts
Re: Get users IP address
Dec 19, 2009 05:27 PM|LINK
just use this code
in code behind page call the function and pass the IP
thats it
hope this help
raji539
Member
46 Points
25 Posts
Re: Get users IP address
Mar 01, 2011 06:12 AM|LINK
if ur want in assemblly..
if ur using web application
Rajesh Kumar Chekuri
http://www.funevil.blogspot.com
http://techtasks.net
chandradev1
Participant
1563 Points
474 Posts
Re: Get users IP address
Mar 03, 2011 03:40 AM|LINK
Hi
check this code
protected void Button1_Click(object sender, EventArgs e) { string strHostName = System.Net.Dns.GetHostName(); string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString(); SqlCommand cmd = new SqlCommand(“insert into tblIpAddress(IPAddress)values(@IPAddress)”, con); cmd.Parameters.AddWithValue(“@IPAddress”, clientIPAddress); con.Open(); cmd.ExecuteNonQuery(); con.Close(); }My Blog
[Life is wonderful if you know how to live life]
prakash.radh...
Member
224 Points
89 Posts
Re: Get users IP address
Mar 03, 2011 03:57 AM|LINK
//use the below code Session["ipAddress"] = Request.ServerVariables["REMOTE_HOST"]; Session["macAddress"] = GetMacAddress(Session["ipAddress"].ToString()); public string GetMacAddress(string IPAddress) { string strMacAddress = string.Empty ; try { string strTempMacAddress= string.Empty ; ProcessStartInfo objProcessStartInfo = new ProcessStartInfo(); Process objProcess = new Process(); objProcessStartInfo.FileName = "nbtstat"; objProcessStartInfo.RedirectStandardInput = false; objProcessStartInfo.RedirectStandardOutput = true; objProcessStartInfo.Arguments = "-A " + IPAddress; objProcessStartInfo.UseShellExecute = false; objProcess = Process.Start(objProcessStartInfo); int Counter = -1; while (Counter <= -1) { Counter = strTempMacAddress.Trim().ToLower().IndexOf("mac address", 0); if (Counter > -1) { break; } strTempMacAddress = objProcess.StandardOutput.ReadLine(); } objProcess.WaitForExit(); strMacAddress = strTempMacAddress.Trim(); } catch (Exception Ex) { //Console.WriteLine(Ex.ToString()); //Console.ReadLine(); } return strMacAddress; }Thanks & Regards
Prakash Radhwani