I was using the following statement to get Client's computername. It works for several days(actually over a week) then suddently it does not work any more. DiscountASP.Net support person said they did not make any changes on the web hosting site. Does any one have any clue why it stops working. Or do you have a better way to get the computer name? Thanks! System.Net.Dns.GetHostEntry(Request.ServerVariables["remote_addr"]).HostName.Split(new char[] { '.' });
Do you get an error? Is Request.ServerVariable s["remote_addr"] returning an IP? Do you know for sure that that IP has a DNS pointer record? Note that your code does NOT give you the client machine name but rather the reverse DNS lookup of the source IP. In this age, this IP is most likely the IP of the router.
BTW.. this may help too. http://stackoverflow.com/questions/281697/how-do-i-find-the-remote-host-name-in-asp-net/281742
I had tried the link http://stackoverflow.com/questions/2...asp-net/281742 and got the same error. The error was captured by my application error process. The Request.ServerVariables["remote_addr"] does get me the IP address. What I don't understand is, it was working for a few days then stop working. Must be something related to DNS reverse name pointer or something like that. Not sure the following error message will give any hint abouit why. ** Error message captured by application error process at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.wfhome_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\89e3cd85\79552a51\App_Web_wfhome.aspx.cdcab7d2.9y70oiym.0.cs:line 0 at System.Web.HttpApp Request.ServerVariables["remote_addr"] does give me the IP address. I don't know why it works for a few days then stop working. Must be related to DNS reverse name process or something like that. I tried the link Bruce provided and still does not work. I think it is the same error as my original one. My application error process capture this error and the following is the message, hope it will give some clue about why. ** Error message at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.wfhome_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\89e3cd85\79552a51\App_Web_wfhome.aspx.cdcab7d2.9y70oiym.0.cs:line 0 at System.Web.HttpApp
hmm.. the error doesn't tell us much. Have you tried create a simple page that does nothing but display the result of this? System.Net.Dns.GetHostEntry(Request.ServerVariable s["remote_addr"]).HostName.Split(new char[] { '.' }); Try and let us know if you get any error with the test page?
Created a web form with two text box and one button. When Click the button, it will get the IP and Computer name. The Ip works fine but the statement to get the computer name still does not work on the hosting site. However it works on my development server. string ipAddress = Request.ServerVariables["remote_addr"].ToString(); string[] computer_name = System.Net.Dns.GetHostEntry(ipAddress.ToString()).HostName.Split(new char[] { '.' });
Finally found a solution to this problem. Should use the following instead. string[] computer_name = System.Net.Dns.GetHostByAddress(ipAddress.ToString()).HostName.Split(new char[] { '.' }); Check the following link for the temporary solution: http://msdn.microsoft.com/en-us/library/ms143998.aspx Well, this is not really client's computer name. It is the host name. It is better than nothing. Wish there is a way to get the real client's computer name.
Have you tried something like this suggestion: http://bytes.com/groups/javascript/92507-get-computer-name Granted it is not going to work on all systems and there are also browser security settings to be considered that can prevent it from working at all, but it does have the potential to determine the actual client computer name (not the hostname via reverse DNS) because it is a client side method.
Thank you Sorry for not reading the forum for a while. Since the approach requires users to lower security setting, it does not address my need. Thanks!