Introduction:
In this article I will explain how to get or find IP address of client machine in asp.net using JQuery.
In this article I will explain how to get or find IP address of client machine in asp.net using JQuery.
Description:
In previous posts I explained many articles relating to JQuery. Now I will explain how to get client machine IP address of client machine in asp.net using jquery. To implement this one write the code as shown below
In previous posts I explained many articles relating to JQuery. Now I will explain how to get client machine IP address of client machine in asp.net using jquery. To implement this one write the code as shown below
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Get Find IP Address of
Client machine using JQuery in asp.net</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$("#btnSubmit").click(function() {
$.getJSON("http://jsonip.appspot.com?callback=?",
function(data) {
alert("Your IP Address: " + data.ip);
})
.error(function() { alert("error");
})
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:button ID="btnSubmit" runat="server"
Text="Get IP
Address" />
</form>
</body>
</html>
|
If
you observe script in header section here we are calling webservice using JSON
calls this service is called as JSONP because we included parameter string “callback=?” in URL.
Demo
Your IP
Address:
180.151.55.134 |
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
7 comments :
Hi Suresh,
I tried this URL and it's working gud, but if your system in some domain then it's give me the server IP address not the exact Client IP Address.
Sorry if something is wrong..
Great Work keep doing this.
Rajeev
It is giving me the same IP address
Please Tell Me HOw TO Get The Connection I Got The Display The Error Message.My Code Is :-
using (SqlConnection test = new SqlConnection("Data Source=ANKIT\MSSQLSERVER1;Integrated Security=true;Initial Catalog=demo"))
{
using (SqlCommand cmdSQL = new SqlCommand("select DISTINCT UserName from auto_table where UserName LIKE '%'+@SearchText+'%'", test))
{
test.Open();
cmdSQL.Parameters.AddWithValue("@SearchText", username);
SqlDataReader dr = cmdSQL.ExecuteReader();
while (dr.Read())
{
result.Add(dr["UserName"].ToString());
}
return result;
}
}
@patel vipul...
please check your database connection..
please give code for webservice in this example
Dear Suresh,
This is not working jquery
This is not working jquery
Note: Only a member of this blog may post a comment.