Is there a way to get the IP address of a client in Silverlight if my Silverlight control is hosted in HTML?
A:
Try the methods listed below (first one should usually do the trick), or see here for more info.
Request.ServerVariables(”REMOTE_HOST”)
HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]
HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
Request.UserHostAddress()
Request.UserHostName()
string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
Chris Ballance
2009-05-13 14:35:06
this is not for html.. its parameter passing in case of Asp.net.. this is not possible from HTML to my knowledge
Usman Masood
2009-05-14 05:44:38
@Chris I have tried all the methods, I am using ASP.Net (.asmx) web services with Silverlight. since there is no way to find client ip address in Silverlight, therefore I had to log this on service end. all the above methods work fine on my local system, but when i publish my service on production server. it starts giving errors.
Zain Shaikh
2010-03-28 19:22:18
Error: Object reference not set to an instance of an object.StackTrace: at System.Web.Hosting.ISAPIWorkerRequestInProc.GetAdditionalServerVar(Int32 index) at System.Web.Hosting.ISAPIWorkerRequestInProc.GetServerVariable(String name) at System.Web.Hosting.ISAPIWorkerRequest.GetRemoteAddress() at System.Web.HttpRequest.get_UserHostAddress()
Zain Shaikh
2010-03-28 19:23:06
+2
A:
As far as I know there are no direct ways to do this. May be you can create a WebMethod to achieve this. Or some other tricks.
Check this thread, there are some suggestions: http://silverlight.net/forums/t/34744.aspx
NinethSense
2009-05-13 14:38:21
yep! i knew about webservice method idea.... but i thought may be there is any other workaround....
Usman Masood
2009-05-13 14:50:03
+1
A:
I have found this website provides a lot of ways to detect visitors' IP address - http://www.ip2location.com/developers.aspx . Not sure can helping on Silverlight or not. I'm also looking forward to detect my web visitors' IP address and to displaying their geographical location.
hexahow
2010-05-13 09:08:52